Sunday, December 30, 2012

FuelPHP 1. Installation

Installation

1. Download

    http://fuelphp.com

    version 1.4 (as of 1st January 2013)

2. Environment of Apache

    My document_root of Apache is actually J:/www
    But the virutal localhost is J:/vhosts which is configured in httpd-vhosts.conf


    <Directory j:/vhosts>
Order Deny,Allow
Allow from all
    </Directory>

    <VirtualHost *:80>
        DocumentRoot "j:/vhosts"
        ServerName localhost
    </VirtualHost>

    <VirtualHost *:80>
        DocumentRoot "j:/vhosts/words"
        ServerName words
    </VirtualHost>

3. Installation

    I've made 2 directories, one in the document_root (J:/vhosts) and the other in outside the document_root (J:/) and moved the files there

    1. public files: J:/vhosts/words/(assets, htaccess, index.php)

        (Move oil to this directory)


    2. fuel files: J:/fuel/(app, core, packages, htaccess, LICENSE)


4. Edit firephp/index.php

    This index.php is actually found in public/index.php from the downloaded archive
    But now in J:/vhosts/words/index.php

    The links to the installed programs are modified

    /**
     * Path to the application directory.
     */
    define('APPPATH', realpath(__DIR__.'/../../fuel/app/').DIRECTORY_SEPARATOR);

    /**
     * Path to the default packages directory.
     */
    define('PKGPATH', realpath(__DIR__.'/../../fuel/packages/').DIRECTORY_SEPARATOR);

    /**
     * The path to the framework core.
     */
    define('COREPATH', realpath(__DIR__.'/../../fuel/core/').DIRECTORY_SEPARATOR);


    * modify oil the same as index.php

    visit http://localhost/words to see the installed welcome page


5. Set TimeZone


    Modify app/config/config.php


return array( 'default_timezone' => 'Asia/Seoul', );


    Test the timezone by touching J:/fuel/app/views/welcome/index.php

    <h1>Welcome!</h1>
    <?php echo date("Y-m-d H:i:s"); ?>

    visit http://localhost/words to see the localized date time


6. Visit HOME

    http://localhost/words/

    This will visit the fuelphp located under the document_root
    And is routed to the fuelphp application pages as indicated by the words/index.php

    The chain of links to the welcome page is as follows

    http://localhost/words/
    ==> J:/vhosts/words/index.php
    ==> J:/fuel/app/bootstrap.php
    ==> J:/fuel/app/classes/controller/welcome.php
    ==> action_index() in controller/welcome.php
    ==> J:/fuel/app/views/welcome/index.php

    if you add hello to the above url, you will see another demo page

    http://localhost/words/hello

    which calls one method called function action_hello() in welcome.php

7. Change the Default Page


    It is possible to change the route of the first page which is automatically directed when the url has nothing but the base_url like http://www.world.com/

    Edit the config file named routes.php in app/config


    return array(
    '_root_'  => 'main/index',  // The default route
    '_404_'   => 'main/404',    // The main 404 route

    'hello(/:name)?' => array('main/hello', 'name' => 'hello'),
    );

 

8. Test oil

    To execute php, add the path to php.exe to the environment variable in the computer system

        c:\wamp\bin\php\php5.3.5;

    Then go to the oil directory (now in J:/vhosts/words), and run windows cmd utility

    And run oil as

        J:\vhosts\words> php oil








No comments:

Post a Comment