Commit: ffa2351114a9ccb0f08e908d34843f4747f515ec

Author: psychic | Date: 2010-08-25 15:36:59 -0600
Restructuring getting started content: moving out request guide, consolidating setup info.
diff --git a/01_getting_started/01_installation.wiki b/01_getting_started/01_installation.wiki index 1368d03..aa51695 100644 --- a/01_getting_started/01_installation.wiki +++ b/01_getting_started/01_installation.wiki @@ -2,7 +2,11 @@ ## Getting the Code -Li3's source is housed in a Git repo. Start by creating a new account at [http://rad-dev.org/users/add](http://rad-dev.org/users/add). Once you've successfully created your new account, add your SSH key at [http://rad-dev.org/users/account](http://rad-dev.org/users/account). If you've never completed that process before, sometimes its as simple as typing in 'ssh-keygen' in a console. +This easiest way to get a fresh copy of Lithium is by downloading an archive from our website. You can view and download versions here: + + http://rad-dev.org/lithium/versions + +Li3's source is also housed in a Git repo. If you'd like to clone a copy, start by creating a new account at [http://rad-dev.org/users/add](http://rad-dev.org/users/add). Once you've successfully created your new account, add your SSH key at [http://rad-dev.org/users/account](http://rad-dev.org/users/account). If you've never completed that process before, sometimes its as simple as typing in 'ssh-keygen' in a console. $ ssh-keygen @@ -37,6 +41,13 @@ For the purposes of this guide, we'll assume you're running Apache. Before start Another quick thing to check is to make sure that magic quotes have been completely disabled in your PHP installation. If you're seeing an exception error message initially, you might have magic quotes enabled. For more information on disabling this feature, see the [PHP manual](http://www.php.net/manual/en/security.magicquotes.disabling.php). +While you're making PHP configuration changes, you might also consider having PHP display errors temporarily during development. Just change the relevant lines in your php.ini: + +{{{ + error_reporting = E_ALL + display_errors = true +}}} + Finally, pull up li3 in your browser. For this example, we're running Apache locally. Assuming you have a default configuration, and you cloned Lithium into your document root directory, you can visit [`http://localhost/lithium`](http://localhost/lithium). At this point, you should be presented with the Li3 default home page. You're up and running! diff --git a/01_getting_started/a-typical-request.wiki b/01_getting_started/a-typical-request.wiki deleted file mode 100644 index 45d5ec8..0000000 --- a/01_getting_started/a-typical-request.wiki +++ /dev/null @@ -1,35 +0,0 @@ -# A Typical Lithium Request - -When building an application with Lithium, it's important to understand how a typical request is handled. This gives you a better idea of the possibilities inherent in the system, and allows you to better troubleshoot any problems that might arise during development. - -## Initial Request and Bootstrapping - -While a Lithium application can be configured a number of different ways, the safest is by pointing your web server to the `/app/webroot` folder inside the application. It can be pointed at the root directory of the application, but either way, the request is forwarded on until `/app/webroot/index.php` handles it. - -This directory index file does two things: first, it loads up Lithium's main bootstrap file (and any related bootstrap files therein). Second, it instantiates the dispatcher, and hands its `run()` method a new `Request` object. The `Request` object aggregates all the GET / POST / environment data, and is the canonical source of any of that information throughout the life of the request. - -## Request Dispatching & Routing - -Once `Dispatcher` has the request, it asks the router to process it. This processing basically matches the request against each configured route, in the order it was defined. Once a match is found, the Router returns parameter information necessary to find a controller class, and dispatch a method call against it. - -Once those parameters have been returned, the Dispatcher uses them to instantiate the correct controller object, and invokes it. The invokation logic in each controller informs it on which action to call to handle the response. - -## Action Rendering - -Each controller action contains a set of business logic to build a facet or interface in your application. It may interact with models or other classes to fetch, validate, sanitize, and process the data. - -Once the data is ready for the view layer, the action hands it off either through `$this->set()`, or by returning an associative array. That data is passed, along with information about the response type, to the Media class. - -## The Media Class - -The Media class facilitates content-type mapping (mapping between content-types and file extensions), handling static assets, and globally configuring how the framework handles output in different formats. - -Once the controller action data and request has been passed to Media, it matches the request with the correct response type, and triggers the view layer accordingly. Most often this results in rendering an HTML view (and its elements) inside of an HTML layout. - -Media is extremely flexible, however, and the response could result in JSON serialization, XML formatting, or writing out the contents of an audio file to the output buffer. Content type mapping is done by calling `Media::type()`, usually in a bootstrap file. - -## Content Output - -Finally, the response content, along with any headers, are packed into a response class, which is passed by the controller back up to `Dispatcher`. The dispatcher returns the Response object to index.php, where it is echoed to the output buffer. - -This echo writes the headers, and performs a buffered output of whatever content was returned from the Media class. \ No newline at end of file diff --git a/01_getting_started/apache-setup.wiki b/01_getting_started/apache-setup.wiki deleted file mode 100644 index af6bfa2..0000000 --- a/01_getting_started/apache-setup.wiki +++ /dev/null @@ -1,22 +0,0 @@ -There are many ways to set up apache to serve Lithium apps. We'll try to stick to the basics here. - -The location of your Apache config file depends on your environment, but it usually goes by 'httpd.conf' or 'apache.conf'. Assuming you don't plan to use a virtual host (if you don't know what that means, you can safely assume you aren't), the _DocumentRoot_ directive should be set to \_your Lithium directory\_>/app: ```DocumentRoot "_your Lithium directory_>/app".``` - -Typically, you'll also have to loosen some restrictions on the home directory with some simple directives. The following is an example of a configuration that works for Lithium: - -{{{ -<Directory "_your Lithium directory_/app"> - # Basic directives to let Lithium do its thing - Options Indexes FollowSymLinks - - # Let our .htaccess file set any directive - AllowOverride all - - # Let anyone request resources from anywhere - Allow from all -</Directory> -}}} - -Note that this is **not** a good configuration for production servers. Make sure you know what you're doing before configuring Apache for production use. - -At this point you should see the Lithium welcome page when you request 'http://localhost' in your browser. \ No newline at end of file diff --git a/01_getting_started/data_sources/mongodb-setup.wiki b/01_getting_started/data_sources/mongodb-setup.wiki new file mode 100644 index 0000000..c86c8aa --- /dev/null +++ b/01_getting_started/data_sources/mongodb-setup.wiki @@ -0,0 +1,51 @@ + MongoDB is a 'document oriented' or 'NOSQL' database. Document oriented databases have many advantages over more traditional relational databases, including high performance and much simpler scalability. Many developers also like its schema-less nature, allowing the app to add fields to records as needed. + +It is important to understand, however, that MongoDB is _not_ a replacement for relational DBs. Relational DB maintain the advantage of much more powerful queries- especially when it comes to complex relations. + +With that said, we'll leave it to the MongoDB folks to explain [how to set up MongoDB itself](http://www.mongodb.org/display/DOCS/Getting+Started). + +Steps for installing the PHP driver depend on your OS. + +##For *NIX: +For MongoDB + PHP goodness, you'll need the Mongo PECL module. For most *NIX systems, this is as easy as: + + sudo pecl install mongo + +Now add the following line to your php.ini: + +Add the following line to your php.ini: + + extension=mongo.so + +That's it! You're done! + +##For Windows: + +The precompiled driver is available for the following setups: +VC8 and VC9 + +Builds for each release are available on Github. They are all build for PHP 5.3, as PHP 5.2 is no longer supported with VC9. + +Binaries for the latest code are also available: + + * VC8 Thread-Safe + * VC8 Non-Thread-Safe + * VC9 Thread-Safe + * VC9 Non-Thread-Safe + +VC6 + +The latest binaries for 5.2 and 5.3 are available at php.net. + +Please inquire on the mailing list if you need a different build. +Install + +1. Download and extract the .zip file. Make sure PHP version_ matches the version of PHP you are running (e.g., if you are running PHP 5.2.6, download the driver for PHP 5.2). +2. Copy php_mongo.dll to your PHP extensions directory (see "extension_dir" in php.ini). +3.Add the following line to your php.ini: + +extension=php_mongo.dll + +For more information about using MongoDB, take a look at [MongoDB Quickstart](http://www.mongodb.org/display/DOCS/Quickstart). + +For more information about installing MongoDB alongside PHP, refer to http://www.mongodb.org/display/DOCS/Installing+the+PHP+Driver \ No newline at end of file diff --git a/01_getting_started/mongodb-setup.wiki b/01_getting_started/mongodb-setup.wiki deleted file mode 100644 index c86c8aa..0000000 --- a/01_getting_started/mongodb-setup.wiki +++ /dev/null @@ -1,51 +0,0 @@ - MongoDB is a 'document oriented' or 'NOSQL' database. Document oriented databases have many advantages over more traditional relational databases, including high performance and much simpler scalability. Many developers also like its schema-less nature, allowing the app to add fields to records as needed. - -It is important to understand, however, that MongoDB is _not_ a replacement for relational DBs. Relational DB maintain the advantage of much more powerful queries- especially when it comes to complex relations. - -With that said, we'll leave it to the MongoDB folks to explain [how to set up MongoDB itself](http://www.mongodb.org/display/DOCS/Getting+Started). - -Steps for installing the PHP driver depend on your OS. - -##For *NIX: -For MongoDB + PHP goodness, you'll need the Mongo PECL module. For most *NIX systems, this is as easy as: - - sudo pecl install mongo - -Now add the following line to your php.ini: - -Add the following line to your php.ini: - - extension=mongo.so - -That's it! You're done! - -##For Windows: - -The precompiled driver is available for the following setups: -VC8 and VC9 - -Builds for each release are available on Github. They are all build for PHP 5.3, as PHP 5.2 is no longer supported with VC9. - -Binaries for the latest code are also available: - - * VC8 Thread-Safe - * VC8 Non-Thread-Safe - * VC9 Thread-Safe - * VC9 Non-Thread-Safe - -VC6 - -The latest binaries for 5.2 and 5.3 are available at php.net. - -Please inquire on the mailing list if you need a different build. -Install - -1. Download and extract the .zip file. Make sure PHP version_ matches the version of PHP you are running (e.g., if you are running PHP 5.2.6, download the driver for PHP 5.2). -2. Copy php_mongo.dll to your PHP extensions directory (see "extension_dir" in php.ini). -3.Add the following line to your php.ini: - -extension=php_mongo.dll - -For more information about using MongoDB, take a look at [MongoDB Quickstart](http://www.mongodb.org/display/DOCS/Quickstart). - -For more information about installing MongoDB alongside PHP, refer to http://www.mongodb.org/display/DOCS/Installing+the+PHP+Driver \ No newline at end of file diff --git a/01_getting_started/servers/apache-setup.wiki b/01_getting_started/servers/apache-setup.wiki new file mode 100644 index 0000000..af6bfa2 --- /dev/null +++ b/01_getting_started/servers/apache-setup.wiki @@ -0,0 +1,22 @@ +There are many ways to set up apache to serve Lithium apps. We'll try to stick to the basics here. + +The location of your Apache config file depends on your environment, but it usually goes by 'httpd.conf' or 'apache.conf'. Assuming you don't plan to use a virtual host (if you don't know what that means, you can safely assume you aren't), the _DocumentRoot_ directive should be set to \_your Lithium directory\_>/app: ```DocumentRoot "_your Lithium directory_>/app".``` + +Typically, you'll also have to loosen some restrictions on the home directory with some simple directives. The following is an example of a configuration that works for Lithium: + +{{{ +<Directory "_your Lithium directory_/app"> + # Basic directives to let Lithium do its thing + Options Indexes FollowSymLinks + + # Let our .htaccess file set any directive + AllowOverride all + + # Let anyone request resources from anywhere + Allow from all +</Directory> +}}} + +Note that this is **not** a good configuration for production servers. Make sure you know what you're doing before configuring Apache for production use. + +At this point you should see the Lithium welcome page when you request 'http://localhost' in your browser. \ No newline at end of file diff --git a/01_getting_started/setup.wiki b/01_getting_started/setup.wiki deleted file mode 100644 index a2ce263..0000000 --- a/01_getting_started/setup.wiki +++ /dev/null @@ -1,42 +0,0 @@ -## Setting Up Your Environment - -In this tutorial we'll be using: - -* HTTP Server (Apache + mod_rewrite recommended for this tutorial) -* PHP 5.3.0 or higher -* One of the following databases: CouchDB, MongoDB, MySQL, or SQLite. Don't worry about the database for now- we'll get to that later in the tutorial. - -You can try deploying the blog on a different HTTP server, but you're on your own here. - -PHP 5.3 is a hard requirement for Li3. You'll see that this is a good thing as you build your blog. - -Now for the moment you've been waiting for- let's get a fresh copy of Lithium. You have 2 options: - -1) Download the latest version from http://rad-dev.org/lithium/versions. For security reasons, it's best to extract the Li3 archive in a directory outside of the web root folder. We'll get in to more detail on this later. - -2) Use Git to clone the latest version from the Li3 repository: http://rad-dev.org/lithium/wiki/guides/installation. This is the best option for getting the latest and greatest version, or if you plan to contribute code and/or documentation yourself. Check out (pun intended?) our [Git setup guide](http://rad-dev.org/lithium/wiki/drafts/wllm/tutorial/Git_Setup) to set up your Git installation for Lithium. - -Now you should make sure your HTTP server is on board. Here's a guide to get Apache serving your Lithium application in no time: [http://rad-dev.org/lithium/wiki/drafts/wllm/tutorial/Apache_Setup](http://rad-dev.org/lithium/wiki/drafts/wllm/tutorial/Apache_Setup). - -Just to make sure any errors you might run aren't quietly eaten, make sure the following line are in your php.ini file: - -``` -error_reporting = E_ALL -display_errors = true -``` - -If you're now serving up the Lithium welcome page, you have a platform to deploy your blog on. - -Finally, to make it easier to access the Lithium RAD tool from anywhere on your file system, you should the executable to your system path. For *NIX systems running bash, you can do this by adding the following line to your .profile file: - -``` -PATH=$PATH:_your Lithium directory_/libraries/lithium/console -``` - -For Windows, you can simply add it after a semicolon to the _Path_ variable in the System properties dialog. - -If you can run the _li3_ command from your command line, you're ready to start developing your blog application. - - - - diff --git a/02_request_response/a-typical-request.wiki b/02_request_response/a-typical-request.wiki new file mode 100644 index 0000000..45d5ec8 --- /dev/null +++ b/02_request_response/a-typical-request.wiki @@ -0,0 +1,35 @@ +# A Typical Lithium Request + +When building an application with Lithium, it's important to understand how a typical request is handled. This gives you a better idea of the possibilities inherent in the system, and allows you to better troubleshoot any problems that might arise during development. + +## Initial Request and Bootstrapping + +While a Lithium application can be configured a number of different ways, the safest is by pointing your web server to the `/app/webroot` folder inside the application. It can be pointed at the root directory of the application, but either way, the request is forwarded on until `/app/webroot/index.php` handles it. + +This directory index file does two things: first, it loads up Lithium's main bootstrap file (and any related bootstrap files therein). Second, it instantiates the dispatcher, and hands its `run()` method a new `Request` object. The `Request` object aggregates all the GET / POST / environment data, and is the canonical source of any of that information throughout the life of the request. + +## Request Dispatching & Routing + +Once `Dispatcher` has the request, it asks the router to process it. This processing basically matches the request against each configured route, in the order it was defined. Once a match is found, the Router returns parameter information necessary to find a controller class, and dispatch a method call against it. + +Once those parameters have been returned, the Dispatcher uses them to instantiate the correct controller object, and invokes it. The invokation logic in each controller informs it on which action to call to handle the response. + +## Action Rendering + +Each controller action contains a set of business logic to build a facet or interface in your application. It may interact with models or other classes to fetch, validate, sanitize, and process the data. + +Once the data is ready for the view layer, the action hands it off either through `$this->set()`, or by returning an associative array. That data is passed, along with information about the response type, to the Media class. + +## The Media Class + +The Media class facilitates content-type mapping (mapping between content-types and file extensions), handling static assets, and globally configuring how the framework handles output in different formats. + +Once the controller action data and request has been passed to Media, it matches the request with the correct response type, and triggers the view layer accordingly. Most often this results in rendering an HTML view (and its elements) inside of an HTML layout. + +Media is extremely flexible, however, and the response could result in JSON serialization, XML formatting, or writing out the contents of an audio file to the output buffer. Content type mapping is done by calling `Media::type()`, usually in a bootstrap file. + +## Content Output + +Finally, the response content, along with any headers, are packed into a response class, which is passed by the controller back up to `Dispatcher`. The dispatcher returns the Response object to index.php, where it is echoed to the output buffer. + +This echo writes the headers, and performs a buffered output of whatever content was returned from the Media class. \ No newline at end of file