Skip to content

Instantly share code, notes, and snippets.

@asilbalaban
Created January 14, 2015 16:00
Show Gist options
  • Save asilbalaban/ece12de738f128d81b87 to your computer and use it in GitHub Desktop.
Save asilbalaban/ece12de738f128d81b87 to your computer and use it in GitHub Desktop.
How to install fuelphp and setup ormauth on it!

Installing and Setup FuelPHP's Ormauth

Create new project with Oil

$ oil create <project_name>

In your project there is a fuel/packages folder Copy /fuel/packages/auth/config/auth.php and /fuel/packages/auth/config/ormauth.php files to your main config folder which is /fuel/app/config/

Change the driver in /fuel/app/config/auth.php's line 25 Simpleauth to Ormauth be careful its case sensetive After that change your salt on line 27

Now you can edit /fuel/app/config/ormauth.php as you wish

In /fuel/app/config/config.php you need to uncomment always load section and autoload orm and auth packages.

Your config.php's betweenLine 258 to Line 313 should look like this

	/**************************************************************************/
	/* Always Load                                                            */
	/**************************************************************************/
	'always_load'  => array(

		/**
		 * These packages are loaded on Fuel's startup.
		 * You can specify them in the following manner:
		 *
		 * array('auth'); // This will assume the packages are in PKGPATH
		 *
		 * // Use this format to specify the path to the package explicitly
		 * array(
		 *     array('auth'	=> PKGPATH.'auth/')
		 * );
		 */
		'packages'  => array(
			'orm',
			'auth',
		),

		/**
		 * These modules are always loaded on Fuel's startup. You can specify them
		 * in the following manner:
		 *
		 * array('module_name');
		 *
		 * A path must be set in module_paths for this to work.
		 */
		'modules'  => array(),

		/**
		 * Classes to autoload & initialize even when not used
		 */
		'classes'  => array(),

		/**
		 * Configs to autoload
		 *
		 * Examples: if you want to load 'session' config into a group 'session' you only have to
		 * add 'session'. If you want to add it to another group (example: 'auth') you have to
		 * add it like 'session' => 'auth'.
		 * If you don't want the config in a group use null as groupname.
		 */
		'config'  => array(),

		/**
		 * Language files to autoload
		 *
		 * Examples: if you want to load 'validation' lang into a group 'validation' you only have to
		 * add 'validation'. If you want to add it to another group (example: 'forms') you have to
		 * add it like 'validation' => 'forms'.
		 * If you don't want the lang in a group use null as groupname.
		 */
		'language'  => array(),
	),

After do that you can ready to run migrations. But before that we need to setup our database connection edit /fuel/app/config/development/db.php

Run first migration for create users table and users groups tables etc..

oil refine migrate --packages=auth

Performed migrations for package:auth:
001_auth_create_usertables
002_auth_create_grouptables
003_auth_create_roletables
004_auth_create_permissiontables
005_auth_create_authdefaults
006_auth_add_authactions
007_auth_add_permissionsfilter

If you want to example module you can generate page module with this command

oil generate admin pages title:string slug:string summary:text body:text publisher:int

Creating controller: /Applications/MAMP/htdocs/cms/fuel/app/classes/controller/base.php
Creating controller: /Applications/MAMP/htdocs/cms/fuel/app/classes/controller/admin.php
Creating views: /Applications/MAMP/htdocs/cms/fuel/app/views/admin/template.php
Creating views: /Applications/MAMP/htdocs/cms/fuel/app/views/admin/dashboard.php
Creating views: /Applications/MAMP/htdocs/cms/fuel/app/views/admin/login.php
Creating migration: /Applications/MAMP/htdocs/cms/fuel/app/migrations/001_create_pages.php
Creating model: /Applications/MAMP/htdocs/cms/fuel/app/classes/model/page.php
Creating controller: /Applications/MAMP/htdocs/cms/fuel/app/classes/controller/admin/pages.php
Creating view: /Applications/MAMP/htdocs/cms/fuel/app/views/admin/pages/index.php
Creating view: /Applications/MAMP/htdocs/cms/fuel/app/views/admin/pages/view.php
Creating view: /Applications/MAMP/htdocs/cms/fuel/app/views/admin/pages/create.php
Creating view: /Applications/MAMP/htdocs/cms/fuel/app/views/admin/pages/edit.php
Creating view: /Applications/MAMP/htdocs/cms/fuel/app/views/admin/pages/_form.php
Creating view: /Applications/MAMP/htdocs/cms/fuel/app/views/template.php

oil refine migrate

Performed migrations for app:default:
001_create_pages

Done

Installation and setup done. Now you can login admin panel on http://yourproject.dev/admin your username and password admin you can see examples at here

@azazqadir
Copy link

Installing FuelPHP and other such PHP frameworks is really easy on a server if you are using a php mysql web hosting provider that provides pre-configured server where you don't even have to install composer. This way you can start right from installing FuelPHP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment