Thursday, November 29, 2012

Setting Up FuelPHP on your Server


Download
fuelphp.com
https://github.com/downloads/fuel/fuel/fuelphp-1.4.zip









save as c:\wamp\www\
extract contents to root
http://localhost/


go to
http://localhost/public


Apache -> Apache Modules -> rewrite_module
create .htaccess or copy one
clear
add these code
SetEnv FUEL_ENV production
<IfModule mod_rewrite.c>
    RewriteEngine on

    RewriteBase /public

    RewriteRule ^(/)?$ index.php/$1 [L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>


Ecommerce Data Model





19 comments:

  1. <?php
    Class Controller_Welcome extends Controller {
    public function action_index() {
    echo 'Hello World';
    // return Response::forge('Hello World');
    }
    }

    ReplyDelete
  2. $view = View::forge('hello_world');
    $view->name='chris';
    return Response::forge($view);

    ReplyDelete
  3. 'tarzan', 'girl'=>'jane'));
    return Response::forge($view);
    }

    public function action_love($boy,$girl) {

    $view = View::forge('hello_world');
    $view->girl=$girl;
    $view->boy=$boy;
    return Response::forge($view);
    }


    }

    ReplyDelete
  4. 'tarzan', 'girl'=>'jane'));
    return Response::forge($view);
    }

    public function action_love($boy,$girl) {

    $view = View::forge('hello_world');
    $view->girl=$girl;
    $view->boy=$boy;
    return Response::forge($view);
    }


    }

    ReplyDelete
  5. 'tarzan', 'girl'=>'jane'));
    return Response::forge($view);
    }

    public function action_love($boy,$girl) {

    $view = View::forge('hello_world');
    $view->girl=$girl;
    $view->boy=$boy;
    return Response::forge($view);
    }


    }

    ReplyDelete
  6. edit c:\fuel\app\config\development\db.php

    return array(
    'default' => array(
    'connection' => array(
    'dsn' => 'mysql:host=localhost;dbname=shop',
    'username' => 'root',
    'password' => '',
    ),
    ),
    );

    ReplyDelete
    Replies
    1. same content for c:\fuel\app\config\production\db.php

      Delete
  7. Add ORM (/fuel/app/config/config.php)

    return array(
    'always_load' => array('packages' => array('orm',)),
    );

    ReplyDelete
  8. return array(
    'always_load' => array('packages' => array('orm',)),
    );

    ReplyDelete
  9. php oil g controller classroom index view list name hello world

    ReplyDelete
  10. to check if successful:

    type the url localhost/public/index.php/classroom/

    ReplyDelete
  11. http://localhost/public/index.php/classroom/

    ReplyDelete
  12. To create the migration file:
    type in the command prompt:

    php oil g scaffold users username:varchar[10] password:varchar age:tinyint sex:tinyint

    To migrate (i.e. have these changes be applied to the database):
    Type in the command prompt:

    php oil refine migrate

    ReplyDelete
    Replies
    1. make sure that your config.php db.php (development and production) are correct (see previous posts)

      Delete
  13. To add Users:

    1. Go to http://localhost/public/index.php/users/create

    ReplyDelete
  14. 'base_url' => 'http://fuelphp.demo/public/index.php/',

    ReplyDelete
  15. 'base_url' => 'http://localhost/public/index.php/',

    ReplyDelete
  16. Model Name: custommodel.php


    namespace Model;
    use DB;
    class Custommodel extends \Model {


    public static function find_data($field, $value, $tablename) {

    $result = DB::select('*')->from($tablename)->where($field, $value)->execute();

    return $result;

    }


    }

    ReplyDelete
  17. Controller Name: products.php

    use \Model\Custommodel;

    public function action_view($id = null)
    {


    $data['product'] = Custommodel::find_data('slug', $id, 'products');


    $this->template->title = "Product";
    $this->template->content = View::forge('admin\products/view', $data);

    }

    ReplyDelete