Skip to content

Commit

Permalink
Update docs - managing apps
Browse files Browse the repository at this point in the history
  • Loading branch information
jim-parry committed Jan 3, 2019
1 parent d79e5bf commit 37110d5
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 43 deletions.
1 change: 1 addition & 0 deletions public/index.php
Expand Up @@ -14,6 +14,7 @@
// Location of the Paths config file.
// This is the line that might need to be changed, depending on your folder structure.
$pathsPath = FCPATH . '../app/Config/Paths.php';
// ^^^ Change this if you move your application folder

/*
*---------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions spark
Expand Up @@ -34,6 +34,7 @@ define('FCPATH', __DIR__ . '/public' . DIRECTORY_SEPARATOR);

// Load our paths config file
require 'app/Config/Paths.php';
// ^^^ Change this line if you move your application folder

$paths = new Config\Paths();

Expand Down
6 changes: 4 additions & 2 deletions user_guide_src/source/concepts/structure.rst
Expand Up @@ -9,7 +9,7 @@ Default Directories
===================

A fresh install has six directories: ``/app``, ``/system``, ``/public``,
``/writable``, ``/tests`` and ``/docs``.
``/writable``, ``/tests`` and possibly ``/docs``.
Each of these directories has a very specific part to play.

app
Expand Down Expand Up @@ -77,11 +77,13 @@ production servers.

docs
----
This directory holds a local copy of the CodeIgniter4
If this directory is part of your project, it holds a local copy of the CodeIgniter4
User Guide.

Modifying Directory Locations
-----------------------------

If you've relocated any of the main directories, you can change the configuration
settings inside ``app/Config/Paths``.

Please read `Managing your Applications <../general/managing.html>`_
2 changes: 1 addition & 1 deletion user_guide_src/source/database/transactions.rst
Expand Up @@ -76,7 +76,7 @@ debugging is turned off, you can manage your own errors like this::
}

Disabling Transactions
=====================
======================

Transactions are enabled by default. If you would like to disable transactions you
can do so using $this->db->transOff()::
Expand Down
78 changes: 38 additions & 40 deletions user_guide_src/source/general/managing_apps.rst
Expand Up @@ -8,54 +8,52 @@ directory. It is possible, however, to have multiple sets of
applications that share a single CodeIgniter installation, or even to
rename or relocate your application directory.

Renaming the Application Directory
==================================
Renaming or Relocating the Application Directory
================================================

If you would like to rename your application directory you may do so
as long as you open **app/Config/Paths.php** file and set its name using
the ``$applicationDirectory`` variable::
If you would like to rename your application directory or even move
it to a different location on your server, other than your project root, open
your main **app/Config/Paths.php** and set a *full server path* in the
``$appDirectory`` variable (at about line 38)::

$applicationDirectory = 'application';
public $appDirectory = '/path/to/your/application';

Relocating your Application Directory
=====================================
You will need to modify two additional files in your project root, so that
they can find the ``Paths`` configuration file:

It is possible to move your application directory to a different
location on your server than your web root. To do so open
your main **app/Config/Paths.php** and set a *full server path* in the
``$appDirectory`` variable::
- ``/spark`` runs command line apps; the path is specified on or about line 36::

require 'app/Config/Paths.php';
// ^^^ Change this if you move your application folder


- ``/public/index.php`` is the front controller for your webapp; the config
path is specified on or about line 16::

$pathsPath = FCPATH . '../app/Config/Paths.php';
// ^^^ Change this if you move your application folder

$appDirectory = '/path/to/your/application';

Running Multiple Applications with one CodeIgniter Installation
===============================================================

If you would like to share a common CodeIgniter installation to manage
several different applications simply put all of the directories located
inside your application directory into their own sub-directory.
If you would like to share a common CodeIgniter framework installation, to manage
several different applications, simply put all of the directories located
inside your application directory into their own (sub)-directory.

For example, let's say you want to create two applications, named "foo"
and "bar". You could structure your application directories like this::

applications/foo/
applications/foo/config/
applications/foo/controllers/
applications/foo/libraries/
applications/foo/models/
applications/foo/views/
applications/bar/
applications/bar/config/
applications/bar/controllers/
applications/bar/libraries/
applications/bar/models/
applications/bar/views/

To select a particular application for use requires that you open your
main index.php file and set the ``$application_directory`` variable. For
example, to select the "foo" application for use you would do this::

$application_directory = 'applications/foo';

.. note:: Each of your applications will need its own **index.php** file
which calls the desired application. The **index.php** file can be named
anything you want.
and "bar". You could structure your application project directories like this::

foo/app, public, tests and writable
bar/app/, public, tests and writable
codeigniter/system and docs

This would have two apps, "foo" and "bar", both having standard application directories
and a ``public`` folder, and sharing a common codeigniter framework.

The ``index.php`` inside each application would refer to its own configuration,
``.../app/Config/Paths.php``, and the ``$systemDirectory`` variable inside each
of those would be set to refer to the shared common "system" folder.

If either of the applications had a command-line component, then you would also
modify ``spark`` inside each application's project folder, as directed above.

0 comments on commit 37110d5

Please sign in to comment.