From 2ede2f6e8e9f2cde7402a88906d091011f7885ec Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Wed, 10 Mar 2010 15:00:18 -0600 Subject: added docs for application Packages, added third_party folder to the application folder --- system/application/third_party/index.html | 10 +++++++ user_guide/changelog.html | 1 + user_guide/libraries/loader.html | 49 +++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 system/application/third_party/index.html diff --git a/system/application/third_party/index.html b/system/application/third_party/index.html new file mode 100644 index 000000000..c942a79ce --- /dev/null +++ b/system/application/third_party/index.html @@ -0,0 +1,10 @@ + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + \ No newline at end of file diff --git a/user_guide/changelog.html b/user_guide/changelog.html index 5b61993c1..38ccc2fcf 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -71,6 +71,7 @@ Hg Tag:

  • Added routing overrides to the main index.php file, enabling the normal routing to be overridden on a per "index" file basis.
  • Added the ability to set config values (or override config values) directly from data set in the main index.php file. This allows a single application to be used with multiple front controllers, each having its own config values.
  • Added $config['directory_trigger'] to the config file so that a controller sub-directory can be specified when running _GET strings instead of URI segments.
  • +
  • Added ability to set "Package" paths - specific paths where the Loader and Config classes should try to look first for a requested file. This allows distribution of sub-applications with their own libraries, models, config files, etc. in a single "package" directory. See the Loader class documentation for more details.
  • In-development code is now hosted at BitBucket.
  • Libraries diff --git a/user_guide/libraries/loader.html b/user_guide/libraries/loader.html index 83b3831e2..cc5210238 100644 --- a/user_guide/libraries/loader.html +++ b/user_guide/libraries/loader.html @@ -190,6 +190,55 @@ it will instead return the data as a string.

    This function is an alias of the config file loading function: $this->config->load()

    +

    Application "Packages"

    + +

    An application package allows for the easy distribution of complete sets of resources in a single directory, complete with its own libraries, models, helpers, config, and language files. It is recommended that these packages be placed in the system/application/third_party folder. Below is a sample map of an package directory

    + + +

    Sample Package "Foo Bar" Directory Map

    + +

    The following is an example of a directory for an application package named "Foo Bar".

    + +/system/application/third_party/foo_bar
    +
    +config/
    +helpers/
    +language/
    +libraries/
    +models/
    +
    + +

    Whatever the purpose of the "Foo Bar" application package, it has its own config files, helpers, language files, libraries, and models. To use these resources in your controllers, you first need to tell the Loader that you are going to be loading resources from a package, by adding the package path.

    + +

    $this->load->add_package_path()

    + +

    Adding a package path instructs the Loader class to prepend a given path for subsequent requests for resources. As an example, the "Foo Bar" application package above has a library named Foo_bar.php. In our controller, we'd do the following:

    + +$this->load->add_package_path(APPPATH.'third_party/foo_bar/');
    +$this->load->library('foo_bar');
    + +

    $this->load->remove_package_path()

    + +

    When your controller is finished using resources from an application package, and particularly if you have other application packages you want to work with, you may wish to remove the package path so the Loader no longer looks in that folder for resources. To remove the last path added, simply call the method with no parameters.

    + +

    $this->load->remove_package_path()

    + +

    Or to remove a specific package path, specify the same path previously given to add_package_path() for a package.:

    + +$this->load->remove_package_path(APPPATH.'third_party/foo_bar/'); + +

    Package view files

    + +

    @todo - package view file interface is not complete. It can be experimentally used by first saving the Loader's original view path, setting the view path to the package's view path, and when finished, setting back to the original view path.

    + +// ... save the original view path, and set to our Foo Bar package view folder
    +$orig_view_path = $this->load->_ci_view_path;
    +$this->load->_ci_view_path = APPPATH.'third_party/foo_bar/views/';
    +
    +// ... code using the package's view files
    +
    +// ... then return the view path to the application's original view path
    +$this->load->_ci_view_path = $orig_view_path;
    -- cgit v1.2.3-24-g4f1b