├── .gitignore ├── favicon.ico ├── favicon.png ├── assets ├── img │ ├── fuel.png │ ├── clear.gif │ ├── handle.png │ ├── point.png │ ├── h-split.png │ ├── header-bg.jpg │ ├── profiler.png │ └── v-split.png └── fonts │ ├── BebasNeue-webfont.eot │ ├── BebasNeue-webfont.ttf │ ├── BebasNeue-webfont.woff │ ├── DroidSans-Bold-webfont.eot │ ├── DroidSans-Bold-webfont.ttf │ └── DroidSans-Bold-webfont.woff ├── classes ├── cache │ └── advanced.html ├── database │ ├── qb.html │ ├── introduction.html │ └── qb_delete.html ├── markdown.html ├── redis.html ├── mongo │ └── introduction.html ├── file │ ├── intro.html │ └── advanced.html ├── theme │ └── advanced.html ├── profiler.html └── package.html ├── vendor ├── intro.html ├── phpquickprofiler.html ├── spyc.html ├── markdown.html ├── htmlawed.html └── phpseclib.html ├── packages ├── oil │ ├── console.html │ ├── refine.html │ ├── package.html │ └── intro.html ├── orm │ ├── observers │ │ ├── intro.html │ │ └── creating.html │ ├── relations │ │ ├── belongs_to.html │ │ ├── has_one.html │ │ └── has_many.html │ └── intro.html ├── parser │ └── intro.html ├── auth │ ├── drivers.html │ ├── intro.html │ └── simpleauth │ │ └── acl.html └── email │ └── usage.html ├── license.html ├── general ├── controllers │ └── hybrid.html ├── tasks.html ├── constants.html ├── mvc.html ├── environments.html ├── classes.html ├── hmvc.html ├── migrations.html ├── profiling.html ├── packages.html └── extending_core.html ├── credits.html ├── templates └── index.html ├── requirements.html ├── index.html ├── contribute.html └── installation ├── download.html └── instructions.html /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | nbproject 3 | *.tmproj -------------------------------------------------------------------------------- /favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srea/docs/HEAD/favicon.ico -------------------------------------------------------------------------------- /favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srea/docs/HEAD/favicon.png -------------------------------------------------------------------------------- /assets/img/fuel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srea/docs/HEAD/assets/img/fuel.png -------------------------------------------------------------------------------- /assets/img/clear.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srea/docs/HEAD/assets/img/clear.gif -------------------------------------------------------------------------------- /assets/img/handle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srea/docs/HEAD/assets/img/handle.png -------------------------------------------------------------------------------- /assets/img/point.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srea/docs/HEAD/assets/img/point.png -------------------------------------------------------------------------------- /assets/img/h-split.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srea/docs/HEAD/assets/img/h-split.png -------------------------------------------------------------------------------- /assets/img/header-bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srea/docs/HEAD/assets/img/header-bg.jpg -------------------------------------------------------------------------------- /assets/img/profiler.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srea/docs/HEAD/assets/img/profiler.png -------------------------------------------------------------------------------- /assets/img/v-split.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srea/docs/HEAD/assets/img/v-split.png -------------------------------------------------------------------------------- /assets/fonts/BebasNeue-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srea/docs/HEAD/assets/fonts/BebasNeue-webfont.eot -------------------------------------------------------------------------------- /assets/fonts/BebasNeue-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srea/docs/HEAD/assets/fonts/BebasNeue-webfont.ttf -------------------------------------------------------------------------------- /assets/fonts/BebasNeue-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srea/docs/HEAD/assets/fonts/BebasNeue-webfont.woff -------------------------------------------------------------------------------- /assets/fonts/DroidSans-Bold-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srea/docs/HEAD/assets/fonts/DroidSans-Bold-webfont.eot -------------------------------------------------------------------------------- /assets/fonts/DroidSans-Bold-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srea/docs/HEAD/assets/fonts/DroidSans-Bold-webfont.ttf -------------------------------------------------------------------------------- /assets/fonts/DroidSans-Bold-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srea/docs/HEAD/assets/fonts/DroidSans-Bold-webfont.woff -------------------------------------------------------------------------------- /classes/cache/advanced.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 13 | 14 | Cache Advanced - Classes - FuelPHP Documentation 15 | 16 | 17 |
18 | 40 | 41 |
42 |
43 |
44 |
45 | 46 |
47 | 48 |

Cache Class

49 | 50 |

The cache class allows you to cache the result of a resource heavy operation.

51 | 52 |
53 |

Advanced usage

54 | 55 |

Here we'll explain how to use caches as object instances.
56 | To be written.

57 |
58 | 59 |
60 | 61 | 66 |
67 | 68 | 69 | -------------------------------------------------------------------------------- /vendor/intro.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Vendor additions - introduction - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 | 47 |

Third Party Vendor packages

48 | 49 |

Introduction

50 | 51 |

52 | The FuelPHP core comes with several vendor packages pre-installed. Vendor packages are libraries from external parties that 53 | are integrated into the FuelPHP core. 54 |

55 | 56 |

Pre-installed packages

57 | 58 | 65 | 66 |
67 | 68 | 73 |
74 | 75 | 76 | -------------------------------------------------------------------------------- /packages/oil/console.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Console - Oil Package - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 |
47 | 48 |

Console

49 | 50 |

51 | The console is the quickest way to test out new classes, models and quick code without even having to open up an IDE. 52 | The shell is interactive but due to limitations in PHP it's not quite as interactive as the bash shell unless you 53 | enable the readline extension. Either way it works, readline just makes it better. 54 |

55 | 56 |
$ php oil console
57 | Fuel 1.0.0-dev - PHP 5.3.3 (cli) (Aug 22 2010 19:27:08) [Darwin]
58 | >>> "Hello World!"
59 | Hello World!
60 | >>> 1+5
61 | 6
62 | >>> $i = 1
63 | >>> ++$i
64 | 2
65 | >>> json_encode(array('foo', 'bar'));
66 | ["foo","bar"]
67 | >>> $monkey = Model_Monkey::find('first');
68 | >>> $monkey->title
69 | Bobby the Gibbon
70 | 71 |
72 | 73 |
74 | 75 | 80 |
81 | 82 | 83 | -------------------------------------------------------------------------------- /vendor/phpquickprofiler.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Vendor additions - PHPQuickProfiler - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 | 47 |

PHPQuickProfiler

48 | 49 |

Introduction

50 | 51 |

52 | PHPQuickProfiler a small tool (think Firebug for PHP) to provide profiling and debugging related information to 53 | developers without needing them to add a lot of programmatic overhead to their code. Now, we only need to toggle 54 | one config setting to true and you have access to an automated tool to help create a faster and more consistent 55 | code review experience. 56 |

57 | 58 |

Documentation

59 | 60 |

You can find the original documentation here.

61 | 62 |

FuelPHP Usage

63 | 64 |

65 | The PHPQuickProfiler vendor package is used by FuelPHP in the Profiler class, to display profiling output when the profiler is enabled. 66 |

67 | 68 |

Application Usage

69 | 70 |

71 | You can add data to PHPQuickProfiler through the Profiler class methods. 72 |

73 | 74 |
75 | 76 | 81 |
82 | 83 | 84 | -------------------------------------------------------------------------------- /vendor/spyc.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Vendor additions - spyc - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 | 47 |

spyc

48 | 49 |

Introduction

50 | 51 |

52 | spyc is a simple YAML parser library for PHP. 53 |

54 |

55 | YAML(tm) is a human-friendly, cross language, Unicode based data serialization language designed around the common 56 | native data structures of agile programming languages. It is broadly useful for programming needs ranging from configuration 57 | files to Internet messaging to object persistence to data auditing. Together with the Unicode standard for characters, the 58 | YAML specification provides all the information necessary to understand YAML Version 1.1 and to creating programs that 59 | process YAML information. 60 |

61 | 62 |

Documentation

63 | 64 |

You can find the original spyc documentation here.

65 | 66 |

FuelPHP Usage

67 | 68 |

69 | The spyc vendor package is used by FuelPHP in the Config and Lang class drivers, to load files in YAML format. 70 |

71 | 72 |

Application Usage

73 | 74 |

75 | There is no direct access to the spyc package. 76 |

77 | 78 |
79 | 80 | 85 |
86 | 87 | 88 | -------------------------------------------------------------------------------- /vendor/markdown.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Vendor additions - markdown - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 | 47 |

markdown

48 | 49 |

Introduction

50 | 51 |

52 | “Markdown” is two things: a plain text markup syntax, and a software tool that converts the plain text markup to HTML for publishing on the web. 53 |

54 |

55 | The Markdown syntax allows you to write text naturally and format it without using HTML tags. More importantly: in Markdown format, your text 56 | stays enjoyable to read for a human being, and this is true enough that it makes a Markdown document publishable as-is, as plain text. 57 | If you are using text-formatted email, you already know some part of the syntax. 58 |

59 | 60 |

Documentation

61 | 62 |

You can find the original markdown documentation here.

63 | 64 |

FuelPHP Usage

65 | 66 |

67 | The markdown vendor package is used by FuelPHP in the Markdown class, to render strings in markdown syntax. 68 |

69 | 70 |

Application Usage

71 | 72 |

73 | You can access markdown through the Markdown::parse() method. 74 |

75 | 76 |
77 | 78 | 83 |
84 | 85 | 86 | -------------------------------------------------------------------------------- /license.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | License - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 | 47 |

License

48 | 49 |

The MIT License

50 | 51 |

Copyright (c) 2010 - 2011 Fuel Development Team

52 | 53 |

54 | Permission is hereby granted, free of charge, to any person obtaining a copy 55 | of this software and associated documentation files (the "Software"), to deal 56 | in the Software without restriction, including without limitation the rights 57 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 58 | copies of the Software, and to permit persons to whom the Software is 59 | furnished to do so, subject to the following conditions: 60 |

61 | 62 |

63 | The above copyright notice and this permission notice shall be included in 64 | all copies or substantial portions of the Software. 65 |

66 | 67 |

68 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 69 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 70 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 71 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 72 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 73 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 74 | THE SOFTWARE. 75 |

76 | 77 |
78 | 79 | 84 |
85 | 86 | 87 | -------------------------------------------------------------------------------- /general/controllers/hybrid.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Hybrid Controller - General - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 | 47 |

Hybrid Controller

48 | 49 |

50 | The hybrid controller brings together the functionality of both the REST controller and the 51 | Template controller in a single base controller. 52 |

53 | 54 |

55 | For more information about the Template or Rest functionality, see the Controller_Rest or Controller_Template pages. 56 |

57 | 58 |

59 | Like all Controllers, you create a class in the fuel/app/classes/controller directory. 60 | They need to extend the Controller_Hybrid class and are prefixed by default by "Controller_". 61 | Below is an example of the controller "test": 62 |

63 | 64 |
class Controller_Test extends Controller_Hybrid
65 | {
66 | 	// this will be called if you request /test/list from the URL
67 | 	public function action_list()
68 | 	{
69 | 		$this->template->content = 'Hello World!';
70 | 	}
71 | 
72 | 	// this will be called when you do an ajax GET request for /test/list?foo=bar
73 | 	public function get_list()
74 | 	{
75 | 		$this->response(array(
76 | 			'foo' => Input::get('foo'),
77 | 			'baz' => array(
78 | 				1, 50, 219
79 | 			),
80 | 			'empty' => null
81 | 		));
82 | 	}
83 | }
84 | 85 |
86 | 87 | 92 |
93 | 94 | 95 | -------------------------------------------------------------------------------- /classes/database/qb.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Query Builder - Classes - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 | 47 |

Query Building

48 | 49 |

50 | Note: 51 | At the time of writing the query builder classes are reworked so they can handle multiple sql dialects. 52 |

53 |

54 | The abstraction of writing SQL for database queries is done by the Query Builder. The query builder 55 | consists a set of classes, each handling a specific part of the query building process. 56 |

57 |

58 | Using the query builder is will go unnoticed most of the times as the DB class provides shortcuts for 59 | creating new query builder objects. It's advised to use these methods to get the right query builder. this is common 60 | practice and will keep your code readable. 61 |

62 | 63 |

64 | Here are the classes that query builder consists of: 65 |

66 | 67 | 76 | 77 |
78 | 79 | 84 |
85 | 86 | 87 | -------------------------------------------------------------------------------- /general/tasks.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Tasks - General - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 |

Tasks

47 | 48 |

What is a task?

49 | 50 |

Tasks are classes that can be run through the command line or set up as a cron job. They are generally used for background processes, timed tasks and maintenance tasks. Tasks can calls models and other classes just like controllers.

51 | 52 |

Creating a task

53 | 54 |

In Fuel Controllers are put in the fuel/app/tasks directory. Below is an example of the task "example":

55 | 56 |
namespace Fuel\Tasks;
57 | 
58 | class Example
59 | {
60 | 
61 | 	public function run($message = 'Hello!')
62 | 	{
63 | 		echo $message;
64 | 	}
65 | }
66 | 67 |

That will be called via the refine utility within oil:

68 | 69 |
$ php oil refine example "Good morning"
. 70 | 71 |

When just the name of the task is used in the command, the method "run()" is referenced.

72 | 73 |

Splitting tasks into more methods

74 | 75 |

You can add more methods to your task class to break a group of tasks down into more specific tasks which can be called separately.

76 | 77 |
public function current_date()
78 | {
79 | 	echo date('Y-m-d');
80 | }
81 | 82 |

We can then call this method using:

83 | 84 |
$ php oil refine example:current_date
85 | 86 |
87 | 88 | 93 |
94 | 95 | 96 | -------------------------------------------------------------------------------- /vendor/htmlawed.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Vendor additions - htmLawed - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 | 47 |

htmLawed

48 | 49 |

Introduction

50 | 51 |

52 | htmLawed is a highly customizable single-file PHP script to make text secure, and standard- and admin policy-compliant 53 | for use in the body of HTML 4, XHTML 1 or 1.1, or generic XML documents. It is thus a configurable input (X)HTML filter, 54 | processor, purifier, sanitizer, beautifier, etc., and an alternative to the HTMLTidy application. 55 |

56 |

57 | The lawing in of input text is needed to ensure that HTML code in the text is standard-compliant, does not introduce security 58 | vulnerabilities, and does not break the aesthetics, design or layout of web-pages. htmLawed tries to do this by, for example, 59 | making HTML well-formed with balanced and properly nested tags, neutralizing code that may be used for cross-site scripting 60 | (XSS) attacks, and allowing only specified HTML elements/tags and attributes. 61 |

62 | 63 |

Documentation

64 | 65 |

You can find the htmLawed documentation here.

66 | 67 |

FuelPHP Usage

68 | 69 |

70 | The htmLawed vendor package is used by FuelPHP in the security class, to clean user input. 71 |

72 | 73 |

Application Usage

74 | 75 |

76 | You can access htmLawed through the Security::xss_clean() method. 77 |

78 | 79 |
80 | 81 | 86 |
87 | 88 | 89 | -------------------------------------------------------------------------------- /packages/oil/refine.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Generate - Oil Package - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 | 47 |
48 | 49 |

Refine

50 | 51 |

52 | Refine is a tool that lets you run tasks. The idea behind the name is you "refine" Oil to make Fuel. You can read more 53 | specifically about Tasks to see how they are made and what they can be used for. 54 |

55 | 56 | 57 |

An example task can be found here fuel/app/tasks/ called robots.

58 | 59 |
$ php oil refine robots
 60 | 
 61 | 					"KILL ALL HUMANS!"
 62 | 			          _____     /
 63 | 			         /_____\
 64 | 			    ____[\*---*/]____
 65 | 			   /\ #\ \_____/ /# /\
 66 | 			  /  \# \_.---._/ #/  \
 67 | 			 /   /|\  |   |  /|\   \
 68 | 			/___/ | | |   | | | \___\
 69 | 			|  |  | | |---| | |  |  |
 70 | 			|__|  \_| |_#_| |_/  |__|
 71 | 			//\\  <\ _//^\\_ />  //\\
 72 | 			\||/  |\//// \\\\/|  \||/
 73 | 			      |   |   |   |
 74 | 			      |---|   |---|
 75 | 			      |---|   |---|
 76 | 			      |   |   |   |
 77 | 			      |___|   |___|
 78 | 			      /   \   /   \
 79 | 			     |_____| |_____|
 80 | 			     |HHHHH| |HHHHH|
 81 | 
82 | 83 |

84 | Not the most useful example in the world, but it works as a useful example. But you can use 85 | the Cli class to make things more interactive or just run basic model 86 | interaction for cron jobs. 87 |

88 | 89 |
90 | 91 |
92 | 93 | 98 |
99 | 100 | 101 | -------------------------------------------------------------------------------- /credits.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Credits - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 | 47 |

Credits

48 |
Core Developers
49 |

These are the developers that make commits on a near-daily basis, and make all final decisions about the framework.

50 | 57 |
Contributors
58 |

Up to date contributor lists are per repo on github:

59 | 69 | 70 |
71 | 72 | 77 |
78 | 79 | 80 | -------------------------------------------------------------------------------- /vendor/phpseclib.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Vendor additions - PHPSecLib - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 | 47 |

PHPSecLib

48 | 49 |

Introduction

50 | 51 |

52 | The PHP Secure Communications Library contains LGPL-licensed pure-PHP implementations of arbitrary-precision integers, 53 | fully PKCS#1 (v2.1) compliant RSA, DES, 3DES, RC4, Rijndael, AES, SSH-1, SSH-2, and SFTP. This book discusses how to use them. 54 |

55 | 56 |

Documentation

57 | 58 |

You can find the original PHPSecLib documentation here.

59 | 60 |

FuelPHP Usage

61 | 62 |

63 | The PHPSecLib vendor package is used by FuelPHP in the Crypt class, to generate secure hashes, and in the Auth package, which uses PBKDF2. 64 |

65 | 66 |

Application Usage

67 | 68 |

69 | For use in your application the PHPSecLib package has been converted to a namespaced, autoloader friendly library. 70 | You can use it directly from your application. 71 |

72 |
<?php
 73 | /**
 74 |  * Example controller that does an SSH login
 75 |  */
 76 | 
 77 | class Controller_Ssh extends Controller
 78 | {
 79 | 	public function action_index()
 80 | 	{
 81 | 		// connect to my server
 82 | 		$ssh = new \PHPSecLib\Net_SSH2('myserver.example.org');
 83 | 
 84 | 		// login
 85 | 		if ( ! $ssh->login('username', 'password'))
 86 | 		{
 87 | 			throw new \Exception('ssh login failed');
 88 | 		}
 89 | 
 90 | 		// return the view that formats the directory list
 91 | 		return View::forge('ssh/dirinfo', array(
 92 | 			'pwd' => $ssh->exec('pwd'),
 93 | 			'info' => $ssh->exec('ls -la'),
 94 | 		));
 95 | 	}
 96 | }
 97 | 
98 | 99 |
100 | 101 | 106 |
107 | 108 | 109 | -------------------------------------------------------------------------------- /templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Template - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 | 47 |

TODO: Write home page copy.

48 | 49 |

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent non urna vitae erat ultricies malesuada. Phasellus ut semper mauris. Morbi lobortis sem eu tortor fringilla cursus. Nullam consequat commodo massa, vitae aliquet purus pretium vel. Pellentesque eleifend gravida lacus, ac ullamcorper sem suscipit vel. Mauris nec ultrices felis. Suspendisse aliquet, augue vitae sollicitudin pharetra, ante dolor imperdiet risus, sed tincidunt sem leo vestibulum leo. Ut quis quam arcu, non varius sapien. Morbi pharetra, lorem in commodo imperdiet, velit sem ultrices nisl, ultrices accumsan ante felis ut turpis. Fusce in nibh nec orci consequat molestie. Nunc semper congue vestibulum. Aliquam ac auctor felis. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.

50 | 51 |

Suspendisse bibendum sapien sed justo tincidunt dapibus. Duis non iaculis lorem. Suspendisse est ante, volutpat quis hendrerit pulvinar, pharetra vel tortor. Suspendisse sed augue tortor. Aliquam erat volutpat. Phasellus vel enim dui, quis faucibus augue. Suspendisse consequat sagittis sagittis. Duis semper tempor ante et ultrices. Donec vulputate nibh in urna tempor vel feugiat tortor imperdiet. Donec condimentum augue a eros tincidunt sagittis. Nulla sit amet magna enim, at ultricies ipsum. Morbi non ante vitae tellus interdum auctor quis sed augue. Phasellus lacus erat, gravida ut gravida eget, accumsan ut enim. Nunc at dui neque. In non libero in elit pretium aliquet sit amet sed massa. Nunc ut augue sit amet sem suscipit malesuada eu id ante. Proin congue, nisl a imperdiet tincidunt, nunc dui posuere metus, nec ornare arcu felis et justo. Praesent imperdiet, nulla eu consequat facilisis, velit nunc congue metus, non luctus lacus sapien nec nunc. Aliquam euismod lacus quis justo consequat condimentum. Morbi sem elit, gravida sed tempor fermentum, euismod nec nisi.

52 | 53 |
Code would go here...
54 | 55 |
56 | 57 | 62 |
63 | 64 | 65 | -------------------------------------------------------------------------------- /packages/orm/observers/intro.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Introduction - Obervers - Orm Package - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 | 47 |

Orm

48 | 49 |

Orm is short for Object 50 | Relational Mapper which does 2 things: it maps your database table rows to objects and it allows you 51 | to establish relations between those objects.
52 | It follows closely the 53 | Active Record Pattern, but was also influenced by other systems.

54 | 55 | 67 | 68 |
69 |

Adding observers to your model

70 | 71 |

You can add observers in 2 ways: just add the name to have the observer called for all events or with 72 | the observer as name and an array of specific events for which the observer is called.
73 | When the Observer is in the same namespace as the Model and prefixed with Observer_ you can 74 | leave out the "Observer_" prefix. In all other cases you have to provide the full classname.

75 | 76 |
class Model_Article
77 | {
78 | 	protected static $_observers = array(
79 | 		'example', // will call Observer_Example class for all events
80 | 		'Orm\\Observer_CreatedOn' => array('before_insert'), // will only call Orm\Observer_CreatedOn at before_insert event
81 | 	);
82 | }
83 |
84 | 85 |
86 | 87 | 92 |
93 | 94 | 95 | -------------------------------------------------------------------------------- /classes/markdown.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 13 | 14 | Markdown - Classes - FuelPHP Documentation 15 | 16 | 17 |
18 | 40 | 41 |
42 |
43 |
44 |
45 | 46 |
47 | 48 |

Markdown Class

49 | 50 |

A plain text to HTML converter, originally by John Gruber. FuelPHP uses a ported and extended version by Michel Fortin.

51 | 52 |
53 |

parse($text)

54 |

Parses Markdown and returns HTML.

55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 105 | 106 | 107 |
StaticYes
Parameters 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |
ParamDefaultDescription
$textrequiredMarkdown text to parse.
76 |
Returnsstring
Example 85 |
$string = '# About Markdown
 86 | 
 87 | Markdown is a text-to-HTML conversion tool for web writers.
 88 | Markdown allows you to write using an easy-to-read, easy-to-write
 89 | plain text format, then convert it to structurally valid HTML.
 90 | 
 91 | * It features bullet points
 92 | * As well as other handy features';
 93 | 
 94 | echo Markdown::parse($string);
95 |

Returns

96 |
<h1>About Markdown</h1>
 97 | <p>Markdown is a text-to-HTML conversion tool for web writers.
 98 | Markdown allows you to write using an easy-to-read, easy-to-write
 99 | plain text format, then convert it to structurally valid HTML.</p>
100 | <ul>
101 | <li>It features bullet points</li>
102 | <li>As well as other handy features</li>
103 | </ul>
104 |
108 |
109 | 110 |
111 | 112 | 117 |
118 | 119 | 120 | -------------------------------------------------------------------------------- /general/constants.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Constants - General - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 | 47 |

Constants

48 | 49 |

50 | Fuel has four constants in the global namespace to direct you to important directories. Fuel uses them internally to locate classes and other files. 51 | These constants are set in public/index.php. 52 |

53 | 54 |

55 | Note: When you move any of fuel's prime folders (app, core, public, packages) be sure to update your index.php to direct fuel to the right paths. 56 |

57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 70 | 71 | 72 | 73 | 77 | 78 | 79 | 80 | 86 | 87 | 88 | 89 | 93 | 94 | 95 |
KeyDescription
APPPATH 67 | Path to the application directory (/path/to/fuel/app). 68 | This is where your application directories and code reside. 69 |
COREPATH 74 | Path to the core directory (/path/to/fuel/core). 75 | This is where all the Fuel classes live. 76 |
DOCROOT 81 | Path to the location where the 'startup script' is. 82 | For you web application, path to the public directory (/path/to/public). 83 | This is where index.php resides. Everything accessible to user lives and is accessible via the browser. 84 | For oil command, path to where oil command resides. 85 |
PKGPATH 90 | Path to the packages directory (/path/to/fuel/packages). 91 | This is where your packages are installed (when installed through oil). 92 |
96 | 97 |

98 | Note: When you use the Oil package, you have to make the same changes in the 'oil' file in the docroot of your website. 99 |

100 | 101 |

102 | Note: When you want to run unit tests, you have to make the same changes in the 'phpunit.xml' file in the fuelphp core folder. 103 |

104 |
105 | 106 | 111 |
112 | 113 | 114 | -------------------------------------------------------------------------------- /requirements.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Requirements - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 | 47 |

Requirements

48 |
Web Server
49 | 53 |
PHP Version
54 | 57 |
PHP Extensions
58 |

59 | Fuel uses functionality that PHP defines as "extensions". To avoid any possible compatibility issues, Fuel only uses extensions that 60 | are part of the PHP code as documented on the PHP website. If extensions are used that are part of the 61 | PECL repository (which need to be installed manually by a system administrator), Fuel will use them if present, and work around it if not. 62 |

63 |

This is a list of extensions used, and the classes that use them:

64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 76 | 77 | 78 | 79 | 80 | 82 | 83 | 84 | 85 | 86 | 88 | 89 | 90 |
ExtensionUsed inComments
fileinfoUploadDocumentation.
75 | Note that on Windows platforms, a manual installation of a DLL might be needed.
mbstringn/aDocumentation.
81 | If not present, the framework has no multibyte support. You can check the MBSTRING constant to see if your installation has multibyte support enabled.
mcryptCryptDocumentation.
87 | If not present, PHPSecLib is used to emulate its functionality.
91 | 92 | 93 | 99 | 100 |
101 | 102 | 107 |
108 | 109 | 110 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 | 47 |

Welcome to FuelPHP

48 | 49 |

50 | FuelPHP is a simple, flexible, community driven PHP 5 web framework. It was born out of the frustrations people have with the current available frameworks and developed 51 | with support from a community of developers. FuelPHP is extremely portable, works on almost any server and prides itself on clean syntax. 52 |

53 | 54 |

Quick Installation

55 | 56 |

If you value your time and want to get things up and running in seconds instead of minutes, you can use our quick installer instead. Using the curl library, you can install a very basic version of oil. From there you can create new full applications of Fuel.

57 | 58 |
# quick install oil from the web
 59 | $ curl get.fuelphp.com/oil | sh
 60 | # now that oil is installed, create a blog project in a directory called Sites
 61 | $ cd Sites/
 62 | $ oil create blog
63 | 64 |

65 | For more information, see the installation page. 66 |

67 | 68 |

Manual Installation

69 | 70 |

71 | If you can't use the quick installation method, you can also install FuelPHP manually. 72 | You will find detailed instructions on the installation page. 73 |

74 | 75 |

Next steps

76 | 77 | 83 | 84 |

Class API Documentation

85 | 86 |

87 | We provide full API documentation of all classes online. 88 |

89 | 90 |

Development Branch Documentation

91 | 92 |

93 | This documentation reflects the state of the documentation at the time of the latest official FuelPHP release. 94 | For documentation of Fuel's bleeding edge, see our Develop Branch Documentation. 95 |

96 | 97 |
98 | 99 | 104 |
105 | 106 | 107 | -------------------------------------------------------------------------------- /packages/orm/relations/belongs_to.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Belongs To - Relations - Orm Package - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 |

Orm

47 | 48 |

Orm is short for Object 49 | Relational Mapper which does 2 things: it maps your database table rows to objects and it allows you 50 | to establish relations between those objects.
51 | It follows closely the 52 | Active Record Pattern, but was also influenced by other systems.

53 | 54 |
55 |

Relations: Belongs To

56 | 57 |

Has the primary key of the relation kept in its table, belongs to 1 related object. This is the other 58 | side of a HasOne or HasMany relation.

59 | 60 |

Example

61 | 62 |

Let's say we have a model Model_Comment and it belongs to a Model_Post 63 | (which in turn has many comments) the ID of the Model_Post is saved with the Model_Comment 64 | instance in its own table. This means the comments table will have a column 65 | post_id (or something else you configure). If you keep to the defaults all you need to do 66 | is add 'post' to the $_belongs_to static property of the Model_Comment:

67 | 68 |
protected static $_belongs_to = array('post');
69 | 70 |

Below are examples for establishing and breaking belongs-to relations:

71 | 72 |
// both main and related object are new:
 73 | $comment = new Model_Comment();
 74 | $comment->post = new Model_Post();
 75 | $comment->save();
 76 | 
 77 | // both main and related object already exist
 78 | $comment = Model_Comment::find(6);
 79 | $comment->post = Model_Post::find(1);
 80 | $comment->save();
 81 | 
 82 | // break the relationship established above
 83 | $comment = Model_Comment::find(6);
 84 | $comment->post = null;
 85 | $comment->save();
86 | 87 |

Full config example with defaults as values

88 | 89 |
// in a Model_Comment which belong to a post
 90 | protected static $_belongs_to = array(
 91 | 	'post' => array(
 92 | 		'key_from' => 'post_id',
 93 | 		'model_to' => 'Model_Post',
 94 | 		'key_to' => 'id',
 95 | 		'cascade_save' => true,
 96 | 		'cascade_delete' => false,
 97 | 	)
 98 | );
99 |
100 | 101 |
102 | 103 | 108 |
109 | 110 | 111 | -------------------------------------------------------------------------------- /classes/redis.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 13 | 14 | Redis - Classes - FuelPHP Documentation 15 | 16 | 17 |
18 | 40 | 41 |
42 |
43 |
44 |
45 | 46 |
47 | 48 |

Redis Class

49 | 50 |

The Redis class allows you to interact with a Redis key-value store.

51 | 52 |
53 |

instance($name = 'default')

54 |

Create a new named redis instance, or return a named instance if it was created earlier.

55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 88 | 89 | 90 |
StaticYes
Parameters 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |
ParamDefaultDescription
$name
'default'
The name of the redis instance requested, as defined the application config db.php file.
76 |
ReturnsFuel\Core\Redis Object
Example 85 |
// create the Redis 'mystore' instance
 86 | $redis = Redis::instance('mystore');
87 |
91 |
92 | 93 |
94 |

Redis commands

95 |

Once you have created a redis object using the instance() method, every valid redis command (see the Redis Documentation) as a method of that object.

96 |

Some examples:

97 |
// create the Redis 'mystore' instance
 98 | $redis = Redis::instance('mystore');
 99 | 
100 | // create some test data
101 | $redis->rpush('particles', 'proton');
102 | $redis->rpush('particles', 'electron');
103 | $redis->rpush('particles', 'neutron');
104 | 
105 | // fetch the range
106 | $particles = $redis->lrange('particles', 0, -1);
107 | 
108 | // count the number of elements
109 | $particle_count = $redis->llen('particles');
110 | 
111 | // display the results
112 | echo "<p>The {$particle_count} particles that make up atoms are:</p>";
113 | echo "<ul>";
114 | foreach ($particles as $particle) {
115 |   echo "<li>{$particle}</li>";
116 | }
117 | echo "</ul>";
118 | 
119 |
120 | 121 |
122 | 123 | 128 |
129 | 130 | 131 | -------------------------------------------------------------------------------- /packages/orm/relations/has_one.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Has One - Relations - Orm Package - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 |

Orm

47 | 48 |

Orm is short for Object 49 | Relational Mapper which does 2 things: it maps your database table rows to objects and it allows you 50 | to establish relations between those objects.
51 | It follows closely the 52 | Active Record Pattern, but was also influenced by other systems.

53 | 54 |
55 |

Relations: Has One

56 | 57 |

Specifies a one-to-one relationship to another model. The target model must include a 58 | "Belongs To" reference to the current model to allow the inverse 59 | relationship.

60 | 61 |

Example

62 | 63 |

Let's say we have a model Model_User and it has one a Model_Profile 64 | (which in turn belongs to the user). The ID of the Model_User is saved with the Model_Profile 65 | instance in its own table. This means the profiles table will have a column 66 | user_id (or something else you configure), while the user table won't mention the profile. 67 | If you keep to the defaults all you need to do is add 'profile' to the 68 | $_has_one static property of the Model_User:

69 | 70 |
protected static $_has_one = array('profile');
71 | 72 |

Below are examples for establishing and breaking has-one relations:

73 | 74 |
// both main and related object are new:
 75 | $user = new Model_User();
 76 | $user->profile = new Model_Profile();
 77 | $user->save();
 78 | 
 79 | // both main and related object already exist
 80 | $user = Model_User::find(6);
 81 | $user->profile = Model_Profile::find(1);
 82 | $user->save();
 83 | 
 84 | // break the relationship established above
 85 | $user = Model_User::find(6);
 86 | $user->profile = null;
 87 | $user->save();
88 | 89 |

Full config example with defaults as values

90 | 91 |
// in a Model_User which has one profile
 92 | protected static $_has_one = array(
 93 | 	'profile' => array(
 94 | 		'key_from' => 'id',
 95 | 		'model_to' => 'Model_Profile',
 96 | 		'key_to' => 'user_id',
 97 | 		'cascade_save' => true,
 98 | 		'cascade_delete' => false,
 99 | 	)
100 | );
101 |
102 | 103 |
104 | 105 | 110 |
111 | 112 | 113 | -------------------------------------------------------------------------------- /packages/orm/relations/has_many.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Has Many - Relations - Orm Package - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 |

Orm

47 | 48 |

Orm is short for Object 49 | Relational Mapper which does 2 things: it maps your database table rows to objects and it allows you 50 | to establish relations between those objects.
51 | It follows closely the 52 | Active Record Pattern, but was also influenced by other systems.

53 | 54 |
55 |

Relations: Has Many

56 | 57 |

Specifies a one-to-many relationship to another model. The target model must include a 58 | "Belongs To" reference to the current model to allow the inverse 59 | relationship.

60 | 61 |

Example

62 | 63 |

Let's say we have a model Model_Post and it has many Model_Comments 64 | (which in turn belong to the post). The ID of the Model_Post is saved with the Model_Comment 65 | instance in its own table. This means the comments table will have a column 66 | post_id (or something else you configure), while the posts table won't mention the comments. 67 | If you keep to the defaults all you need to do is add 'comments' to the 68 | $_has_many static property of the Model_User:

69 | 70 |
protected static $_has_many = array('comments');
71 | 72 |

Below are examples for establishing and breaking has-many relations:

73 | 74 |
// both main and related object are new:
 75 | $post = new Model_Post();
 76 | $post->comments[] = new Model_Comment();
 77 | $post->save();
 78 | 
 79 | // both main and related object already exist
 80 | $post = Model_Post::find(1);
 81 | $post->comments[6] = Model_Comment::find(6); // assigning it to comments[6] is not required but recommended
 82 | $post->save();
 83 | 
 84 | // break the relationship established above
 85 | $post = Model_Post::find(1);
 86 | unset($post->comments[6]);
 87 | $post->save();
88 | 89 |

Full config example with defaults as values

90 | 91 |
// in a Model_Post which has many comments
 92 | protected static $_has_many = array(
 93 | 	'comments' => array(
 94 | 		'key_from' => 'id',
 95 | 		'model_to' => 'Model_Comment',
 96 | 		'key_to' => 'post_id',
 97 | 		'cascade_save' => true,
 98 | 		'cascade_delete' => false,
 99 | 	)
100 | );
101 |
102 | 103 |
104 | 105 | 110 |
111 | 112 | 113 | -------------------------------------------------------------------------------- /contribute.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Contribute - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 | 47 |

Contribute

48 | 49 |

Introduction

50 | 51 |

52 | Fuel is a community driven framework and is open for contributions from anyone who feels they 53 | can improve it or add a feature that will bring the framework to a higher level. There 54 | are multiple forms in which this can be achieved. From writing tutorials, writing and 55 | releasing packages, to contributing to the official parts of Fuel (Core, Orm, Docs, etc..). 56 |

57 | 58 |

Fixing Bugs

59 | 60 |

61 | When you encounter a bug or see one in the issues list that you can or have resolved, 62 | and you want to contribute it back to the framework. Use GitHub to send a pull request. 63 | Depending on which version you are running the branch you pull on. Follow the next couple 64 | of steps to when you request a pull: 65 |

66 | 67 | 96 | 97 |

Non-bug contributions

98 | 99 |

100 | Non-bug contributions are new features, optimizations and all other alterations. All of these request must be made on the 101 | latest development branch. So pull the 1.3/develop branch, make the changes and request a pull. 102 |

103 | 104 |
105 | 106 | 111 |
112 | 113 | 114 | -------------------------------------------------------------------------------- /packages/oil/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Package - Oil Package - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 | 47 |
48 | 49 |

Package

50 | 51 |

52 | Packages can be installed and downloaded manually but with the help of the package command it can work much quicker. It does this 53 | by looking for packages within a list of sources defined in fuel/core/config/package.php and like any other config file can 54 | be edited there or copied to the fuel/app/config folder. 55 |

56 | 57 |

58 | Oil is smart, so it will check to see if you have Git installed on your computer before it does anything with the package command. 59 | If you do have Git installed Oil will install a package as a Git repository instead of directly downloading the files, meaning 60 | updates, new releases and tracking custom changes to packages could not be easier. 61 |

62 | 63 |

Install

64 | 65 |
$ php oil package install test-package
 66 | Downloading package: git://github.com/philsturgeon/fuel-test-package.git
 67 | remote: Counting objects: 13, done.
 68 | remote: Compressing objects: 100% (11/11), done.
 69 | remote: Total 13 (delta 3), reused 0 (delta 0)
 70 | Receiving objects: 100% (13/13), 10.85 KiB, done.
 71 | Resolving deltas: 100% (3/3), done.
 72 | 
 73 | Cloning into /Users/phil/Sites/fuel/fuel/packages/test-package...
74 | 75 |

76 | If Git is not installed, or the --direct flag is provided then a ZIP file of the package will be downloaded and unzipped 77 | to fuel/packages/packagename. 78 |

79 | 80 |
$ php oil package install test-package --direct
 81 | 	Downloading package: http://github.com/philsturgeon/fuel-test-package/zipball/master
 82 | 	DOCROOT/fuel/packages/test-package/LICENSE.txt
 83 | 	DOCROOT/fuel/packages/test-package/README
 84 | 	DOCROOT/fuel/packages/test-package/classes/association.php
 85 | 	DOCROOT/fuel/packages/test-package/classes/belongsto.php
 86 | 	DOCROOT/fuel/packages/test-package/classes/exception.php
 87 | 	DOCROOT/fuel/packages/test-package/classes/hasmany.php
 88 | 	DOCROOT/fuel/packages/test-package/classes/hasone.php
 89 | 	DOCROOT/fuel/packages/test-package/classes/model.php
90 | 91 |

Un-install

92 | 93 |
$ php oil package uninstall test-package
 94 | Uninstalling package "test-package"
95 | 96 |

Note: Unlike install there is no difference here if Git is installed, it will delete all the same.

97 | 98 |

Update

99 | 100 |

Coming soon...

101 | 102 |
103 | 104 |
105 | 106 | 111 |
112 | 113 | 114 | -------------------------------------------------------------------------------- /general/mvc.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Model-View-Controller - General - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 | 47 |

Model-View-Controller (MVC)

48 | 49 |

What is MVC?

50 | 51 |

MVC is an approach to separating your code depending on what role it plays in your application. In the 52 | application flow it starts with a controller that is loaded. That Controller executes a method which retrieves 53 | data using Models. Once it is done the controller decides what View to load, which contains the output your 54 | visitors get to see.

55 | 56 |

Controllers

57 | 58 |

Fuel's routing decides based on the requested URL what controller to load and what method to call upon it. 59 | This is where your application starts working. The Controller decides what actions to take, what to do with any 60 | user input, what data gets manipulated and which View is shown to the user. The Controller does none of these 61 | things itself however; it calls upon Models and Classes to do the work.

62 | 63 |

Read more about Controllers.

64 | 65 |

Models

66 | 67 |

Whenever data needs to be retrieved, manipulated or deleted this should always be done by a model. A Model 68 | is a representation of some kind of data and has the methods to change them. For example: you never put SQL 69 | queries in a Controller, those are put in the Model and the Controller will call upon the Model to execute 70 | the queries. This way if your database changes you won't need to change all your Controllers but just the 71 | Model that acts upon it.

72 | 73 |

Read more about Models.

74 | 75 |

Views

76 | 77 |

Views contain your HTML, which should never be found in your Controllers or any other class that is not 78 | specifically meant to create output. By separating your layout from your logic you ensure that when you decide 79 | to change your layout you only have to change the views and won't have to care about the Controllers.
80 | Views should thus contain little more than echo and foreach usage of PHP.

81 | 82 |

Read more about Views.

83 | 84 |

ViewModels

85 | 86 |

Once your application gets more complex you'll discover that it gets hard to decide if a piece of logic 87 | really belongs in the Controller, what if it is very specifically about the View and has little to do with your 88 | application logic? This is where ViewModels come in; they are the glue between your controllers and your 89 | views.

90 | 91 |

Read more about ViewModels.

92 | 93 |
94 | 95 | 100 |
101 | 102 | 103 | -------------------------------------------------------------------------------- /general/environments.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Environments - General - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 | 47 |

Environments

48 | 49 |

50 | The support of environments helps FuelPHP and your app to make decisions based on the environment setting. 51 | FuelPHP itself uses the environment setting to load/overwrite additional config setting based on which 52 | environment is currently active. 53 |

54 | 55 |

Environments list

56 | 57 |

58 | FuelPHP has four predefined environments. 59 |

60 | 61 | 79 | 80 |

Set Your Environment

81 | 82 |

83 | Setting your environment is done by setting the FUEL_ENV server var or manually changing the 84 | setting in fuel/app/bootstrap.php. 85 |

86 | 87 |
// Inside app/bootstrap.php
 88 | 
 89 | /**
 90 |  * Your environment.  Can be set to any of the following:
 91 |  *
 92 |  * Fuel::DEVELOPMENT
 93 |  * Fuel::TEST
 94 |  * Fuel::STAGE
 95 |  * Fuel::PRODUCTION
 96 |  */
 97 | Fuel::$env = (isset($_SERVER['FUEL_ENV']) ? $_SERVER['FUEL_ENV'] : Fuel::DEVELOPMENT);
98 | 99 |

Environments and Config

100 | 101 |

102 | Based on the environment the app is set to, the Config class looks for environment-specific config files. 103 | The config class will look for the same config file name in a directory that's named after the current environment. 104 | Here is an example to illustrate this: 105 |

106 | 107 |
app/
108 |   config/
109 |     stuff.php
110 |       development/
111 |         stuff.php
112 |       production/
113 |         stuff.php
114 | 115 |

116 | When your environment is set to \Fuel::DEVELOPMENT, the settings from stuff.php are merged with development/stuff.php. 117 | If the environment setting is set to any other than \Fuel::DEVELOPMENT, the extra config file is not loaded. The same goes 118 | for any other environment setting you might use. 119 |

120 | 121 |

122 | A real-life example for this is the database configuration. There are no default configuration settings (this is possibly 123 | very dangerous). There are only environment-specific config settings. 124 |

125 | 126 |
127 | 128 | 133 |
134 | 135 | 136 | -------------------------------------------------------------------------------- /packages/oil/intro.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Introduction - Oil Package - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 | 47 |

Oil utility

48 | 49 |

The Oil utility is a special package command can be used in several ways to facilitate quick development, help with 50 | testing your application and for running Tasks.

51 | 52 |
53 | 54 |

Oil is an optional command line utility designed to help speed up development by providing several functions:

55 | 56 |
    57 |
  • Generate - Build MVC components, migrations and entire scaffolding.
  • 58 |
  • Refine - Run tasks such as migrate and your own custom ones.
  • 59 |
  • Package - Install, update and remove packages.
  • 60 |
  • Console - Test your code in real time using an interactive shell.
  • 61 |
62 | 63 |

64 | Each of these commands works in a different way to achieve different things, but before getting into them it's best to make sure 65 | you are in the correct folder and oil is available and running. 66 |

67 | 68 |
$ cd Sites/fuel
 69 | $ php oil -v
 70 | Fuel: 1.2
71 | 72 |

Environments

73 | 74 |

75 | Oil won’t use any instructions you’ve made for HTTP requests, such as defining the server environment using .htaccess. Oil will use whichever environment is the default unless you instruct it. 76 |

77 | 78 |
$ FUEL_ENV=production php oil refine migrate
79 | 80 |

In place of production you can use any of the defined environments.

81 | 82 |

In-line help

83 | 84 |

Oil contains its own basic documentation which can be found by typing the command:

85 | 86 |
$ php oil help
 87 | 
 88 | Usage:
 89 |   php oil [console|generate|package|refine|help|test]
 90 | 
 91 | Runtime options:
 92 |   -f, [--force]    # Overwrite files that already exist
 93 |   -s, [--skip]     # Skip files that already exist
 94 |   -q, [--quiet]    # Suppress status output
 95 |   -t, [--speak]    # Speak errors in a robot voice
 96 | 
 97 | Description:
 98 |   The 'oil' command can be used in several ways to facilitate quick development, help with
 99 |   testing your application and for running Tasks.
100 | 
101 | Documentation:
102 |   http://docs.fuelphp.com/packages/oil/intro.html
103 | 
104 | 105 |

Each of these commands has its own help section which can be found by typing:

106 | 107 |
$ php oil generate help
108 | 109 |
110 | 111 |
112 | 113 | 118 |
119 | 120 | 121 | -------------------------------------------------------------------------------- /packages/orm/intro.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Introduction - Orm Package - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 |

Orm

47 | 48 |

Orm is short for Object 49 | Relational Mapper which does 2 things: it maps your database table rows to objects and it allows you 50 | to establish relations between those objects.
51 | It follows closely the 52 | Active Record Pattern, but was also influenced by other systems.

53 | 54 |
55 |

Introduction

56 | 57 |

Unlike many other ActiveRecord implementations, ours is small, fast and dead simple to use. It attempts 58 | to make creating, updating and deleting items from your database as easy as possible. It does this by 59 | doing all the hard work for you.

60 |
61 | 62 |
63 |

Installation

64 | 65 |

The Orm package is included in the Fuel download. All you need to do is enable it in your config.

66 |
'packages' => array(
 67 | 	'orm',
 68 | ),
69 |
70 | 71 |
72 |

Troubleshooting

73 | 74 |

Some common problems and frequent questions.

75 | 76 |

My relations/foreign keys aren't being saved (1)

77 |

This happens most often when you're using the wrong type of relationship. Especially Has-one and 78 | Belongs-to tend to get mixed up. Reread the examples in the docs to make sure you're using the 79 | correct relation types and check if everything is configured correctly.

80 | 81 |

I can't relate objects (2)

82 |

Make sure your model is extending Orm\Model and not Model_Crud.

83 | 84 |

I get an exception that my related model in a package/module can't be found

85 |

Make sure the package or module is loaded by Fuel, otherwise the Autoloader won't be able to find 86 | the class.
87 | And when configuring the related model "model_to" make sure you configure the full 88 | classname, this includes the namespace even if you're in that namespace. Classnames in 89 | strings are always taken from global context, no matter the current namespace context.

90 | 91 |

I get an Orm\FrozenObject exception

92 |

Objects can't be edited while being saved to the database, that prevents circular saving and resaving 93 | already saved objects. This shouldn't happen during normal usage and is most often caused by faulty 94 | configuration of relations.
95 | Sometimes this can be caused by a bug, especially when you're not using a stable release.

96 |
97 | 98 |
99 | 100 | 105 |
106 | 107 | 108 | -------------------------------------------------------------------------------- /general/classes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Classes - General - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 | 47 |

Classes

48 | 49 |

What is a class?

50 | 51 |

A class is just a normal PHP class. It doesn't need to extend anything or follow any conventions other than the naming convention which is the same as all other classes in Fuel.

52 | 53 |
class Session
54 | 55 |

That will be loaded from app/classes/session.php.

56 | 57 |

Loading Classes

58 | 59 |

Unlike some other frameworks classes do not need to be loaded manually. They will be auto-loaded when you refer to them in your code (Controllers, Models, etc).

60 | 61 |

Classes in a sub-directory

62 | 63 |

Just like Controllers, classes must be lower-case with first-letter upper case, while underscores will put the class into a sub-directory.

64 | 65 |
Class Session_Driver
66 | 67 |

That will be loaded from app/classes/session/driver.php

68 | 69 |

Classes and Namespaces

70 | 71 |

72 | To determine which PHP file to load, FuelPHP's autoloader will treat namespaces and class names with underscores exactly the same. 73 | This means that for classes in sub-directories, you can mix-and-match namespaces and underscores to suit your needs. 74 |

75 | 76 |

Take for example a class in the file app/classes/core/system/messages.php. The class in this file can be defined as:

77 | 78 |
// global namespace, fully underscored class name
 79 | class Core_System_Messages {}
 80 | 
 81 | // combine a namespace and underscores
 82 | namespace Core;
 83 | class System_Messages {}
 84 | 
 85 | // or fully namespaced
 86 | namespace Core\System;
 87 | class Messages {}
 88 | 
89 | 90 |

91 | The first method is the one most commonly used and easiest to understand. The namespaced versions are particularly handy if you 92 | combine them with the Use statement in the classes that use the defined class. 93 |

94 | 95 |
96 |

Initializing your class

97 | 98 |

It is possible to have Fuel's autoloader perform certain automated tasks once a class is loaded, 99 | sort of like what __construct() does for instances of a class. You do this by adding 100 | a public static _init() method to the class.

101 | 102 |
class Example {
103 | 	public static function _init()
104 | 	{
105 | 		// this is called upon loading the class
106 | 	}
107 | }
108 | 109 |

If a loaded class has its own _init() method and a parent must be loaded 110 | alongside it, that parent's init method isn't called unless you call it using 111 | parent::_init();

112 |
113 | 114 |
115 | 116 | 121 |
122 | 123 | 124 | -------------------------------------------------------------------------------- /classes/mongo/introduction.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Mongo_Db Introduction - Classes - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 | 47 |

Mongo_Db class

48 | 49 |

Introduction

50 |

51 | The Mongo_Db class provides methods to interact with 52 | Mongo databases. 53 |

54 |

55 | Besides providing the normal insert, select, delete and update functionality it has some management 56 | methods to help you with database utility operations. 57 |

58 | 59 |

Configuration

60 | 61 |

62 | For every Mongo database connection there must be a config in mongo array in app/config/db.php. 63 | Configuration options and explanation are listed below. Every config requires to contain a hostname 64 | and database name. 65 |

66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 |
ParamTypeRequiredDescription
hostnamestringyesthe hostname
databasestringyesthe database name
portnumbernothe port to use in the connection
replicasetstringnothe name of the replicaset to use for the connection
usernamestringnousername used for authentication, ignored if no password has been set
passwordstringnopassword used for authentication, ignored if no password has been set
113 | 114 |

Example config:

115 | 116 |
// Inside app/config/db.php
117 | 
118 | 		'mongo' => array(
119 | 			// This group is used when no instance name has been provided.
120 | 			'default' => array(
121 | 				'hostname'   => 'localhost',
122 | 				'database'   => 'mongo_fuel',
123 | 			),
124 | 
125 | 			// List your own groups below.
126 | 			'my_mongo_connection' => array(
127 | 				'hostname'   => 'localhost',
128 | 				'database'   => 'my_db',
129 | 				'replicaset' => 'replica',
130 | 				'username'   => 'user',
131 | 				'password'   => 'p@s$w0rD',
132 | 			),
133 | 		),
134 | 	
135 | 136 |

Once you have your setting in place you can start using MongoDB.

137 | 138 |

139 | In order to use MongoDB this must be available on your server. To see if you have mongo 140 | support on you server, look for the Mongo section in your phpinfo() or ask you hosting company. 141 |

142 | 143 |
144 | 145 | 150 |
151 | 152 | 153 | -------------------------------------------------------------------------------- /general/hmvc.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | HMVC Requests - General - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 | 47 |

HMVC requests

48 | 49 |

50 | HMVC requests are a great way to separate logic and re-use controller logic in multiple places. 51 | One common use of this is when you use a theme or template engine to generate your pages, 52 | where every page is divided into sections, and sections are populated by widgets. 53 | By using modules to produce the widget output, you can create a highly modular application with easy to re-use components. 54 |

55 | 56 |

You call a module controller method using the Request class:

57 |
// fetch the output of a controller
 58 | $widget = Request::forge('mycontroller/mymethod/parms')->execute();
 59 | echo $widget;
 60 | 
 61 | // or fetch the output of a module
 62 | $widget = Request::forge('mymodule/mycontroller/mymethod/parms', false)->execute();
 63 | echo $widget;
 64 | 
65 |

66 | By default, all requests made are processed by Fuel's routing engine. If you want to request something that isn't routable 67 | (for example because you don't want a browser to request it), you should pass 'false' as second parameter 68 | to the forge() call. If you don't you will end up with a 404 error when you execute the request! 69 |

70 | 71 |

72 | Loading views in HMVC request is the same as in normal requests and controllers accessed by HMVC request 73 | are also approachable via the browser. However, in some cases you may not want the component (for example, a widget) 74 | to be accessed through the browser. In those cases, you'll want to check if the request is made through HMVC or the browser. 75 | The following example shows you how to check for a HMVC request: 76 |

77 | 78 |
<?php
 79 | 
 80 | class Controller_Widget extends Controller
 81 | {
 82 | 
 83 | 	public function action_show()
 84 | 	{
 85 | 		if( ! Request::is_hmvc())
 86 | 		{
 87 | 			// this is the main request
 88 | 		}
 89 | 		else
 90 | 		{
 91 | 			// this is a HMVC request
 92 | 		}
 93 | 	}
 94 | 
 95 | }
96 | 97 |

404 during HMVC requests

98 | 99 |

100 | When a 404 occurs during a HMVC request, a HttpNotFoundException is thrown. If uncaught, it will trigger 101 | the load of the frameworks default 404 page. However, you can prevent this and handle the 404 102 | yourself: 103 |

104 | 105 |
try
106 | {
107 | 	\Request::forge('this_will_fail');
108 | }
109 | catch (HttpNotFoundException $e)
110 | {
111 | 	// deal with it
112 | }
113 | 
114 | 115 |

Traversing Request instances

116 | 117 |

If you want to access other Requests, you can traverse them using two methods: 118 | $request->parent() and $request->children(). The parent is the Request during 119 | which the current Request was created (null for the main Request). The children are all the Requests 120 | created during the current Request.

121 | 122 |
123 | 124 | 129 |
130 | 131 | 132 | -------------------------------------------------------------------------------- /installation/download.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Download Fuel - Installation - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 | 47 |

Download Fuel

48 | 49 |

Fuel is now at v1.2.1. You can download Fuel using the links below:

50 | 51 | 81 |

To install one of the Fuel approved packages from the commandline, use the Oil utility.

82 | 83 |

Contribute to the core

84 | 85 |

Fuel is developed using a community approach and we encourage participation. If you are interested in 86 | contributing, please take a second to read our Coding 87 | Standards. Any contributions that do not meet these guidelines will not be accepted. Otherwise: 88 | fork, commit & make pull-request. If you don't know how: 89 | http://help.github.com/forking/ 90 |

91 | 92 |

Contribute a package

93 | 94 |

95 | Do you have something that might be of interest to other Fuel users? Create a package. 96 | If it's properly coded, and it complies with our Coding Standards, we can publish it on 97 | this page and make it available for installation through the oil commandline utility. 98 |

99 | 100 |
101 | 102 | 107 |
108 | 109 | html> 110 | -------------------------------------------------------------------------------- /packages/parser/intro.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Introduction - Parser Package - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 |

Parser package

47 | 48 |

The Parser package extends the Core View class to be able to use any type of template parser you want.

49 | 50 |
51 |

Introduction

52 | 53 |

The Parser package changes nothing about your the way you work with Views, but it will allow you to 54 | use any template parser you want instead of PHP. The package comes with many drivers for parsers like 55 | Mustache, Markdown, Twig and Smarty.

56 | 57 |

Which parser is used is chosen by the file extension of your view file. Normal views are extended 58 | .php and will use PHP to parse the template, for these the .php extension may 59 | also be omitted. All others have their own specific extension, for example foo.mustache 60 | will use the Mustache driver and foo.tpl will use the Dwoo driver (expected extensions can 61 | be changed in config).

62 | 63 |
64 |

Installation

65 | 66 |

The Parser package is included in the Fuel download. To use it you must first enable it by adding 67 | it to your config:

68 |
'packages' => array(
 69 | 	'parser',
 70 | ),
71 | 72 |

While many drivers are included, most of the libraries are not. Only Mustache and Markdown are 73 | included in the vendor directory of the package and work out of the box. Other parsers 74 | you must download from their own website. If you want them to work without changing config they 75 | are expected in app/vendor/{Lib_name} (where the first character of Lib_name 76 | is capitalized.

77 |
78 | 79 |
80 |

Configuration

81 | 82 |

Parser can be configured in a config/parser.php file and takes the following keys:

83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 99 | 100 | 101 |
ParamTypeDefaultDescription
extensionsarray(array with extensions and View class which parses them) 97 | Defines which extensions are valid and what their View driver is. 98 |
102 |
103 | 104 |
105 |

Runtime Configuration

106 | 107 |

All drivers have a parser() method that will allow you to access the current 108 | Parser object. This is a convention and not a requirement and might be different on 3rd party 109 | drivers.

110 | 111 |
// Clear the cache for a specific Smarty template
112 | $view = View::forge('example.smarty');
113 | $view->parser()->clearCache('example.smarty');
114 | 
115 | // Example static usage
116 | View_Smarty::parser()->clearCache('example.smarty');
117 |
118 | 119 |
120 | 121 |
122 | 123 | 128 |
129 | 130 | 131 | -------------------------------------------------------------------------------- /classes/file/intro.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | File Intro - Classes - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 | 47 |

File Class

48 | 49 |
50 | 51 |

Introduction

52 | 53 |

54 | The File class offers a set of methods for working with files & directories. This can 55 | be done through some helper methods or through a more advanced object oriented method where 56 | all files and directories are wrapped in objects. 57 |

58 | 59 |
60 | 61 |
62 |

Configuration

63 | 64 |

65 | The File class is highly configurable and gives you all the control you need over the behaviour 66 | supplied by the class. Configuration settings vary from restricting filesystem access to setting 67 | drivers by filetype. 68 |

69 | 70 |

71 | The default file config is located at core/config/file.php. To change these settings 72 | create a config file with your own settings at app/config/file.php. 73 |

74 | 75 |

76 | The following configuration values can be defined: 77 |

78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 95 | 96 | 97 | 98 | 99 | 100 | 105 | 106 | 107 | 108 | 109 | 110 | 113 | 114 | 115 | 116 | 117 | 118 | 121 | 122 | 123 | 124 | 125 | 126 | 129 | 130 | 131 | 132 | 133 | 134 | 137 | 138 | 139 |
ParamTypeDefaultDescription
basedirstring
null
92 | The path to the basedir. Defaults to null for no restrictions. 93 | When defined this will restrict the access to that specific directory. 94 |
extensionsarray
null
101 | Array of allowed extensions, null for all. 102 | If defined the File class will only handle the given extentions and 103 | filter out the rest. 104 |
urlstring
null
111 | Base url for files, null for not available. 112 |
use_locksnull
null
119 | Whether to use file locks. Set to true if you want the File class to use them. 120 |
file_driversarray
array
127 | Array of file drivers per extension. These allow you to use custom drivers on a by filetype basis. 128 |
magic_filestring
null
135 | Alternative location of the fileinfo() magic file. If not specified, the system default will be used. 136 |
140 | 141 |
142 | 143 |
144 | 145 | 150 |
151 | 152 | 153 | -------------------------------------------------------------------------------- /general/migrations.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Migrations - General - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 | 47 |

Migrations

48 | 49 |

Migrations are a convenient way for you to alter your database in a structured and organized manner. You could edit fragments of SQL by hand but you would then be responsible for telling other developers that they need to go and run them. You’d also have to keep track of which changes need to be run against the production machines next time you deploy.

50 | 51 |

The database table `migration` tracks which migrations have already been run so all you have to do is update your application files and call Migrate::current() to work out which migrations should be run. The current version is found in core/config/migration.php so like any other config file you should copy this to app/config to make changes.

52 | 53 |

Creating a Migration

54 | 55 |

Create a file in the app/migrations folder. The prefix should be an incremental count starting at 001, do not skip numbers and do not have two numbers that match. The first would be something like app/migrations/001_example.php.

56 |
namespace Fuel\Migrations;
 57 | 
 58 | class Example
 59 | {
 60 | 
 61 |     function up()
 62 |     {
 63 |         \DBUtil::create_table('posts', array(
 64 | 			'id' => array('type' => 'int', 'constraint' => 5),
 65 | 			'title' => array('type' => 'varchar', 'constraint' => 100),
 66 | 			'body' => array('type' => 'text'),
 67 | 		), array('id'));
 68 |     }
 69 | 
 70 |     function down()
 71 |     {
 72 |        \DBUtil::drop_table('posts');
 73 |     }
 74 | }
75 | 76 |

Run a Migration

77 | 78 |

A migration can be run in two ways:

79 | 80 |
    81 |
  1. Migrate class
  2. 82 |
  3. Oil Refine Command
  4. 83 |
84 | 85 |

The oil command there uses the Refine command to call the migrate task.

86 | 87 |
$ php oil refine migrate
 88 | $ php oil refine migrate:current
 89 | $ php oil refine migrate:up
 90 | $ php oil refine migrate:down
 91 | $ php oil refine migrate --version=10
92 | 93 |

94 | Migrations are supported for modules and packages too. You can specify on the oil commandline if you want to 95 | migrate all, or only specific modules and/or packages. If you do, you can use '--default' to indicate you want 96 | to include app migrations. 97 |

98 | 99 |
$ php oil refine migrate -all
100 | $ php oil refine migrate --modules=module1,module2 --packages=package1
101 | $ php oil refine migrate:up --packages=package1
102 | $ php oil refine migrate:down --modules=module1,module2 --default
103 | $ php oil refine migrate --version=10
104 | 105 |

106 | Note: 107 | The migrate:current task is to match your schema to the version listed in fuel/[app|core]/config/migrate.php as if you have just got 108 | a copy of the application, the very latest migration not be the one considered stable. Using oil for migrations will modify this migration 109 | config number so the current command will not be relevant in many situations. 110 |

111 | 112 |
113 | 114 | 119 |
120 | 121 | 122 | -------------------------------------------------------------------------------- /classes/file/advanced.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | File Advanced - Classes - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 | 47 |

Advanced usage

48 | 49 |
50 |

Introduction

51 | 52 |

53 | Aside from the basic static usage of the File class there are also more 54 | complex options available. The first are areas which are basically basepaths it 55 | cannot act outside of and have some configuration options. And when using the File class's methods 56 | on an area they will return objects wrapping directories & files. 57 |

58 | 59 |
60 |

Areas

61 | 62 |

Introduction

63 |

64 | File areas are used to influence file system behaviour. By setting basic restrictions you can 65 | set boundaries to allow a flexible use inside those limits without worrying about unauthorized 66 | access of files and directories. 67 |

68 | 69 |

Configuration

70 |

71 | By default file areas have unlimited access through all directories. There are two ways to set 72 | these configuration values. The quickest way is to pass an array intro the 73 | File::forge() method. 74 |

75 | 76 |
$config = array(
 77 | 	'basedir'		=> DOCROOT.'uploads',
 78 | 	'use_locks'		=> true,
 79 | );
 80 | 
 81 | $area = \File::forge($config);
82 | 83 |

84 | A more centralized way is by defining an area (or more) inside your File config file. To do so, 85 | copy core/config/file.php into app/config/file.php (or create a new one) and 86 | define your area inside the 'areas' array. Now you can get the area by supplying the 87 | string identifier to the File::forge() method. 88 |

89 | 90 |
// inside app/config/file.php
 91 | 'areas' => array(
 92 | 	'my_area' => array(
 93 | 		'basedir'		=> DOCROOT.'uploads',
 94 | 		'use_locks'		=> true,
 95 | 	),
 96 | ),
 97 | 
 98 | // Now get the area
 99 | 
100 | $area = \File::instance('my_area');
101 | 					
102 | 103 |

Usage

104 | 105 |

106 | There are 2 ways to use areas in the File class.
107 | The first is to use areas in a static context, supply a File_Area instance or identifier to the 108 | function you're calling. 109 |

110 | 111 |
// Read the contents of a directory
112 | try
113 | {
114 | 	$dir = File::read_dir('somedir', 0, null, 'my_area');
115 | }
116 | catch(\FileAccessException $e)
117 | {
118 | 	// Operation failed
119 | }
120 | 
121 | 122 |

The second way is to call the functions directly from the area itself.

123 | 124 |
// Get the area
125 | $area = File::instance('my_area');
126 | 
127 | try
128 | {
129 | 	$dir = $area->read_dir('somedir', 0, null);
130 | }
131 | catch(\FileAccessException $e)
132 | {
133 | 	// Operation failed
134 | }
135 | 
136 | 137 |
138 | 139 | 146 |
147 | 148 |
149 | 150 | 155 |
156 | 157 | 158 | -------------------------------------------------------------------------------- /packages/auth/drivers.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Writing your own drivers - Auth Package - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 |

Auth package

47 | 48 |

The Auth package provides a standardized interface for authentication in Fuel. This allows our users to 49 | write their own drivers and easily integrate a new driver to work with old code by keeping the basic methods 50 | consistent.

51 | 52 |
53 |

Writing your own drivers

54 | 55 |

56 | Writing drivers can be done in two ways. Either by extending the Auth driver classes 57 | to create a new driver from scratch or extending the SimpleAuth classes and changing them where needed. 58 |

59 | 60 |

61 | An Auth driver consists of three types of classes working together. These are: 62 |

63 | 64 |
    65 |
  • Login (Auth_Login_Driver).
  • 66 |
  • Group (Auth_Group_Driver).
  • 67 |
  • Acl (Auth_Acl_Driver).
  • 68 |
69 | 70 |

Extending auth classes

71 | 72 |

Extend these classes like so:

73 | 74 |
<?php
 75 | 
 76 | class Auth_Login_MyDriver extends \Auth\Auth_Login_Driver
 77 | {
 78 | 
 79 | 	// Implement all the needed functions and variables defined in the driver class.
 80 | 
 81 | }
 82 | 
 83 | /* End of file mydriver.php */
 84 | 
85 | 86 |

Implementing functions

87 | 88 |

89 | When extending the Auth driver classes take note on the expected return values of each function that needs to be implemented. 90 | Every method supplies an example so you know what needs to be returned. Here is an example: 91 |

92 | 93 |
/**
 94 |  * Get User Identifier of the current logged in user
 95 |  * in the form: array(driver_id, user_id)
 96 |  *
 97 |  * @return  array
 98 |  */
 99 | abstract public function get_user_id();
100 | 101 |

102 | The code above show you the get_user_id function that every driver should have. 103 | Like in all classes you extend that have abstract functions, these functions must be defined in the extended class. 104 | The return type of this function is provided in the comment, in this case array(driver_id, user_id). 105 | In order to get your driver to work alongside other drivers make sure you return the right values or your driver 106 | breaks protocol. 107 |

108 | 109 |

110 | Here is that same function but then the implementation from the SimpleAuth driver. 111 |

112 | 113 |
/**
114 |  * Get the user's ID
115 |  *
116 |  * @return  Array  containing this driver's ID & the user's ID
117 |  */
118 | public function get_user_id()
119 | {
120 | 	if (empty($this->user))
121 | 	{
122 | 		return false;
123 | 	}
124 | 
125 | 	return array($this->id, (int) $this->user['id']);
126 | }
127 | 
128 | 129 |

130 | Once you have everything in place for the new driver. Replace or add it to the auth config. 131 |

132 | 133 |
// Inside config/auth.php array
134 | 
135 | // Add it as a driver
136 | 'driver' => array('SimpleAuth', 'MyDriver'),
137 | 
138 | // or replace the SimpleAuth driver
139 | 'driver' => array('MyDriver'),
140 | 
141 | 142 |
143 | 144 |
145 | 146 | 151 |
152 | 153 | 154 | -------------------------------------------------------------------------------- /general/profiling.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Profiling - General - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 |

Profiling

47 | 48 |

The application profiler bundled with FuelPHP is based on PHP Quick Profiler.

49 | 50 |

What is profiling?

51 | 52 |

53 | The profiler provides profiling and debugging related information without having to add a lot of programmatic overhead 54 | to the code. You only need to toggle one config setting to true and you have access to an automated tool to help create a 55 | faster and more consistent review experience. Since anyone can use it, the profiler also gives you an idea of where the code 56 | stands before the review. 57 |

58 | 59 |

The profiler provides you with a tabbed interface, in which you can find the following information:

60 | 71 | 72 |

A typical profiler screen looks like this:

73 | 74 |

At the bottom of the profiler screen, you will find three options:

75 | 80 | 81 |

Application profiling

82 | 83 |

84 | Profiling your application is disabled by default. You can configure Fuel to activate the profiler via your applications config/config.php file. 85 |

86 |
'profiling'  => true,
 87 | 
88 |

89 | After the profiler has been enabled, you will see it pop up at the bottom of your browser window. 90 |

91 | 92 |

Database profiling

93 | 94 |

95 | Profiling your database connection is disabled by default too. Database profiling is activated on a per connection basis, and can be 96 | activated by setting the 'profiler' option of the connection configuration in your config/db.php to true. 97 |

98 | 99 |
'profiling'  => true,
100 | 
101 |

If you use multiple environments, make sure to select the correct db.php configuration file.

102 | 103 |

Add information to the profiler

104 | 105 |

See the documentation of the Profiler class to see how you can interact with the profiler.

106 | 107 |
108 | 109 | 114 |
115 | 116 | 117 | -------------------------------------------------------------------------------- /general/packages.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Packages - General - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 | 47 |

Packages

48 | 49 |

50 | When it comes to organizing, reuse and share your code, packages are a great way to allow you to do this. 51 | They can contain all sorts of code like models, third-party libraries, configs and so on. 52 | Packages also allow you to extend the core without messing up you app/classes directory. 53 | To clarify what packages are, here are the "is" and "is not" on packages. 54 |

55 | 56 |

Packages...

57 | 63 | 64 |

But..

65 | 69 | 70 |

Installing packages

71 |

Installing packages can be done manually and through oil. To install manually download the package source and place it into your package directory (default in fuel/packages).

72 |

To actually be able to use your it you must either add it to always_load in 73 | app/config/config.php or use Package::load().

74 | 75 |

Creating packages

76 |

To help people understand what you are doing it's best to structure your package like so:

77 | 78 |
/packages
 79 |     /package
 80 |         /bootstrap.php
 81 |         /classes
 82 |             /your.php
 83 |             /classes.php
 84 |             /here.php
 85 |         /config
 86 |             /packageconfig.php
 87 |         /and_so_on
 88 | 
89 | 90 |

91 | Every package is expected to have a bootstrap.php located at the base of the package. 92 | Use the bootstrap to add the package namespace (to global if you wish). And add the classes for better perfomance. 93 |

94 | 95 |
// Add namespace, necessary if you want the autoloader to be able to find classes
 96 | Autoloader::add_namespace('Mypackage', __DIR__.'/classes/');
 97 | 
 98 | // Add as core namespace
 99 | Autoloader::add_core_namespace('Mypackage');
100 | 
101 | // Add as core namespace (classes are aliased to global, thus useable without namespace prefix)
102 | // Set the second argument to true to prefix and be able to overwrite core classes
103 | Autoloader::add_core_namespace('Mypackage', true);
104 | 
105 | // And add the classes, this is useful for:
106 | // - optimization: no path searching is necessary
107 | // - it's required to be able to use as a core namespace
108 | // - if you want to break the autoloader's path search rules
109 | Autoloader::add_classes(array(
110 | 	'Mypackage\\Classname' => __DIR__.'/classes/classname.php',
111 | 	'Mypackage\\Anotherclass' => __DIR__.'/classes/anotherclass.php',
112 | ));
113 | 
114 | 115 |

Once you have your classes in place you can now start using them.

116 | 117 |

Note: if package namespaces aren't aliased to global you must supply the it:

118 | 119 |
// If aliased to global just use
120 | $instance = new Myclass;
121 | 
122 | // When not aliased to global
123 | $instance = new Mynamespace\Myclass;
124 | 
125 | 126 |
127 | 128 | 133 |
134 | 135 | 136 | -------------------------------------------------------------------------------- /packages/orm/observers/creating.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Creating - Observers - Orm Package - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 | 47 |

Orm

48 | 49 |

Orm is short for Object 50 | Relational Mapper which does 2 things: it maps your database table rows to objects and it allows you 51 | to establish relations between those objects.
52 | It follows closely the 53 | Active Record Pattern, but was also influenced by other systems.

54 | 55 |
56 |

Observers: Creating your own

57 | 58 |

You can add any class as an observer by adding the full classname (namespace included) to the Observers 59 | property of your model. There's 2 ways of creating classes that can be used as observers:

60 | 61 |

Extend the Orm\Observer class

62 | 63 |

Create a new class that extends Orm\Observer and create methods for the events upon which you 64 | want your Observer to act. In the example below you want it to act upon after_insert. The 65 | method will be passed the Model instance it is acting upon.

66 | 67 |
class Observer_Something extends Orm\Observer
 68 | {
 69 | 
 70 | 	public function after_insert(Model $model)
 71 | 	{
 72 | 		\Log::info('Succesfully created new object of class '.get_class($model));
 73 | 	}
 74 | }
75 | 76 |

Extensions of the type Orm\Observer are singletons by default, as such you can't use a 77 | method instance() or property $_instance or it won't work anymore. Because of this 78 | methods may be both static or non-static.

79 | 80 |

Have an orm_notify() method

81 | 82 |

When you extend the Orm\Observer class it inherits an orm_notify() method that 83 | will check if there's a method that matches the event and call it when possible. But you can use any 84 | class as an observer as long as it has an orm_notify() method. That will be called on events 85 | and be passed the event name and a Model instance.

86 | 87 |
class Some_Other_Class
 88 | {
 89 | 
 90 | 	// it may have many methods and properties before or after the orm_notify method
 91 | 
 92 | 	public static function orm_notify(Model $model, $event)
 93 | 	{
 94 | 		\Log::info('I was notified of the event '.$event.' on a Model of class '.get_class($model));
 95 | 	}
 96 | }
97 | 98 |

Event names

99 | 100 |
    101 |
  • after_create, called by the __construct() method once the object was created
  • 102 |
  • after_load, called by the __construct() method once an object was loaded from the database
  • 103 |
  • before_save, called by the save() method before anything is done
  • 104 |
  • after_save, called by the save() method after it has completed
  • 105 |
  • before_insert, called when an object is first saved to the database
  • 106 |
  • after_insert, called after an object is first saved to the database
  • 107 |
  • before_update, called when an object is saved to the database (except for the first time)
  • 108 |
  • after_update, called after an object is saved to the database (except for the first time)
  • 109 |
  • before_delete, called when you delete an object from the database
  • 110 |
  • after_delete, called after you delete an object from the database
  • 111 |
  • after_clone, called after an object was successfully cloned
  • 112 |
113 | 114 |
115 | 116 |
117 | 118 | 123 |
124 | 125 | 126 | -------------------------------------------------------------------------------- /classes/theme/advanced.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 13 | 14 | Theme Advanced - Classes - FuelPHP Documentation 15 | 16 | 17 |
18 | 40 | 41 |
42 |
43 |
44 |
45 | 46 |
47 | 48 |

Theme Class

49 | 50 |

51 | The Theme class provides theming to your application. 52 |

53 | 54 |

Asset support

55 | 56 |

57 | Every Theme class instance has it's own instance of the Asset class, to make it easy to load assets from the theme. 58 | The Asset instance is populated with the asset paths of both the active and the fallback theme, which will provide 59 | the same fallback features for your assets as you have for other theme elements like templates and views. 60 |

61 | 62 |

Example:

63 | 64 |
// load an asset using the default theme instance
 65 | echo \Theme::instance()->asset->css('bootstrap.css');
66 | 67 |

Advanced configuration

68 | 69 |

70 | The methods active(), fallback(), 71 | info() and all_info() by default allow you 72 | to pass a string with the name of an installed theme. 73 | These methods allow you to pass an theme definition array instead, which makes it possible to pass extra configuration information. 74 |

75 | 76 |

The following theme variables are defined:

77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 |
ParamTypeDefaultDescription
namestringrequiredThe name of the theme. This must match to a folder in the path specified.
pathstringrequiredThe path of the theme. This must include the name of the theme, and end with a directory separator.
asset_basestringoptional 103 | The base path to the assets of this theme, relative to the application DOCROOT. 104 | If outside the DOCROOT, the path should be fully qualified. 105 | It should end with a directory separator. 106 | If not specified, it will be constructed from the given theme path, the configured assets_folder, 107 | and the configured base_url. 108 |
infoarrayoptionalThe theme's information array. If not defined, it will be created from the information in the theme info file.
find_filebooleanoptionalIf set to true, the Finder::search() method will be used to locate view files and theme info files.
124 | 125 |

Example:

126 | 127 |
// standard usage: create an instance and set the active theme
128 | $theme = \Theme::forge();
129 | $theme->active('darkglow');
130 | 
131 | // advanced usage
132 | \Config::load('theme', true, false, true);
133 | $config = \Config::get('theme', false);
134 | 
135 | // override some config values
136 | $config['info_file_name'] = 'setup.info';
137 | $config['info_file_type'] = 'ini';
138 | 
139 | // create the theme instance
140 | $theme = \Theme::forge($config);
141 | 
142 | // set the active theme
143 | $theme->active(
144 | 	array(
145 | 		'name' => 'darkglow',
146 | 		'path' => APPPATH.'themes'.DS.'darkglow'.DS,
147 | 		'asset_base' => '/themes/darkglow/assets/',
148 | 		'find_file' => true,
149 | 	)
150 | );
151 | 	
152 | 153 |
154 | 155 | 160 |
161 | 162 | 163 | -------------------------------------------------------------------------------- /classes/database/introduction.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Database Introduction - Classes - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 | 47 |

Database Introduction

48 | 49 |
50 | 51 |

Introduction

52 | 53 |

54 | Fuel offers a driver based database abstraction layer. At the time of writing supported 55 | drivers are MySQL, MySQLi and PDO. Aside from regular database interaction, fuel also 56 | comes with a DBUtil class to perform database operations such as creating databases, 57 | adding fields and much more. 58 |

59 | 60 |

Please note that not all features are supported by every driver.

61 |
62 | 63 |
64 |

Configuration

65 | 66 |

67 | In order to begin working with databases, you must change the database settings. The 68 | database config file is located at APPPATH/config/db.php. 69 |

70 |

71 | Database configurations are formated like so: 72 |

73 |
// a MySQL driver configuration
 74 | 'development' => array(
 75 | 	'type'           => 'mysqli',
 76 | 	'connection'     => array(
 77 | 		'hostname'       => 'localhost',
 78 | 		'port'           => '3306',
 79 | 		'database'       => 'fuel_db',
 80 | 		'username'       => 'your_username',
 81 | 		'password'       => 'y0uR_p@ssW0rd',
 82 | 		'persistent'     => false,
 83 | 	),
 84 | 	'table_prefix'   => '',
 85 | 	'charset'        => 'utf8',
 86 | 	'enable_cache'   => true,
 87 | 	'profiling'      => false,
 88 | ),
 89 | 
 90 | // a PDO driver configuration
 91 | 'production' => array(
 92 | 	'type'           => 'pdo',
 93 | 	'connection'     => array(
 94 | 		'dsn'            => 'mysql:host=localhost;dbname=fuel_db',
 95 | 		'username'       => 'your_username',
 96 | 		'password'       => 'y0uR_p@ssW0rd',
 97 | 		'persistent'     => false,
 98 | 	),
 99 | 	'table_prefix'   => '',
100 | 	'charset'        => 'utf8',
101 | 	'enable_cache'   => true,
102 | 	'profiling'      => false,
103 | ),
104 |

All Config Settings

105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 |
SettingTypeDescription
typestringWhat type of connection to use. Can be mysq, mysqli or pdo.
connectionarrayConnection settings array
connection.dnsstringConnection DNS for PDO.
connection.usernamestringConnection user.
connection.passwordstringConnection password.
connection.persistentbooleanWether to initiate a persisten connection.
table_prefixstringTable prefix.
charsetstringConnection charset.
enable_cachebooleanWether to allow caching, will overwrite query cache settings on a connection basis.
profilingbooleanWether to add the connections queries to the profiler.
164 |

165 | Once you have your configuration in place, it's time to use it. 166 |

167 |
168 | 169 |
170 | 171 | 176 |
177 | 178 | 179 | -------------------------------------------------------------------------------- /classes/profiler.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 13 | 14 | Profiler - Classes - FuelPHP Documentation 15 | 16 | 17 |
18 | 40 | 41 |
42 |
43 |
44 |
45 | 46 |
47 | 48 |

Profiler Class

49 | 50 |

The profiler class allows you to add your own profiling information to the profiler.

51 | 52 |
53 |

mark($label)

54 |

55 | The mark method will add a speed marker to the profiler. 56 | This marker will show in the "Load Time" section of the profiler. 57 |

58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 90 | 91 | 92 |
StaticYes
Parameters 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 |
ParamDefaultDescription
$labelrequiredA text label to describe the marker to be set.
79 |
Returnsvoid
Example 88 |
Profiler::mark('start of this piece of code');
89 |
93 |
94 | 95 |
96 |

mark_memory($var, $name)

97 |

98 | The mark_memory method will add a memory marker to the profiler. 99 | If you pass a variable, the memory usage of that variable will be logged. 100 | If not, the memory usage at the time of marking will be logged. 101 |

102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 139 | 140 | 141 |
StaticYes
Parameters 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 |
ParamDefaultDescription
$varfalseThe variable whose size has to be logged. If false or not specified, PHP memory usage will be logged.
$name'Memory Usage'A text label to describe the marker to be set.
128 |
Returnsvoid
Example 137 |
Profiler::mark_memory($this, 'Controller_Welcome object');
138 |
142 |
143 | 144 |
145 |

log($text)

146 |

147 | The log method will add a log entry to the profiler. 148 |

149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 181 | 182 | 183 |
StaticYes
Parameters 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 |
ParamDefaultDescription
$textrequiredA text to describe the log entry to be set.
170 |
Returnsvoid
Example 179 |
Profiler::log('start of this piece of code');
180 |
184 |
185 | 186 |
187 | 188 | 193 |
194 | 195 | 196 | -------------------------------------------------------------------------------- /packages/auth/intro.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Introduction - Auth Package - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 |

Auth package

47 | 48 |

The Auth package provides a standardized interface for authentication in Fuel. This allows our users to 49 | write their own drivers and easily integrate a new driver to work with old code by keeping the basic methods 50 | consistent.

51 | 52 |
53 |

Introduction

54 | 55 |

Creating an Auth package that will suit everyone or every implementation is impossible. As a framework 56 | we don't want to force how you do Auth, but we do want to facilitate you creating your own or using the 57 | work of others. This is where the Auth package comes in, which of course includes a simple implementation to 58 | get you going.

59 | 60 |

The interface contains 3 types of drivers (which can be extended to more types): login, groups & ACL. 61 | The login drivers handle a user login and can handle multiple login drivers at the same time. For example 62 | one could make it possible for users to login through Twitter and their own native users at the same time 63 | using 2 login drivers.
64 | As a next step you could group those 2 types of logins using a group driver that doesn't care about the 65 | type of login you're using. And last but not least you can use an Acl driver to give specific rights to 66 | those groups.

67 | 68 |

The above is just an example of how you might use it, not how you have to use it. Read on in 69 | the next section to understand which methods are part of the generic interface and which will be driver 70 | specific: Basic usage and Writing drivers.

71 | 72 |
73 |

Installation

74 | 75 |

The Auth package is included in the Fuel download. All you need to do is enable it in your config.

76 |
'packages' => array(
 77 | 	'auth',
 78 | ),
79 |
80 | 81 |
82 |

Configuration

83 | 84 |

Auth can be configured in a config/auth.php file and takes the following keys:

85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 101 | 102 | 103 | 104 | 105 | 106 | 110 | 111 | 112 | 113 | 114 | 115 | 118 | 119 | 120 |
ParamTypeDefaultDescription
driverstring|array
array('SimpleAuth')
99 | Login drivers to load, the first will also be the default returned by Auth::instance(). 100 |
verify_multiple_loginsbool
false
107 | Whether checking for login continues after one driver has validated a login successfully, 108 | this makes it possible to login in multiple ways at the same time. 109 |
saltstring
'put_your_salt_here'
116 | The salt used for password hashing. 117 |
121 | 122 |

123 | Note that 'verify_multiple_logins' is a driver level setting. It has no meaning for 124 | login drivers, it does not mean "allow a user to be logged-in multiple times"! 125 |

126 | 127 |

Your auth config file should look like this:

128 | 129 |
<?php
130 | 
131 | return array(
132 | 	// The drivers
133 | 	'driver' => array('SimpleAuth'),
134 | 
135 | 	// Set to true to allow multiple logins
136 | 	'verify_multiple_logins' => true,
137 | 
138 | 	// Use your own salt for security reasons
139 | 	'salt' => 'Th1s=mY0Wn_$@|+',
140 | );
141 | 
142 | /* End of file auth.php */
143 | 
144 | 145 |
146 | 147 |
148 | 149 |
150 | 151 | 156 |
157 | 158 | 159 | -------------------------------------------------------------------------------- /general/extending_core.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Extending Core - General - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 | 47 |

Extending Core Classes

48 | 49 |

Be sure to know what you are doing, extended core methods under the same name will be used by the 50 | core as well as by your application and this may result in unexpected behavior.

51 | 52 | 58 | 59 |
60 |

Extending but not replacing the core class

61 | 62 |

These are the easiest and will work like any other class you create; just make them extend the core class 63 | in the global namespace:

64 | 65 |
class MyConfig extends Config {}
66 |
67 | 68 |
69 |

Extending & replacing core classes

70 | 71 |

If you want your core extension to be used by the core as well as by your own application you need to extend 72 | it under the same name but take it from the "Fuel\Core" namespace. Below is an example for the Lang class 73 | which you create in "fuel/app/classes/lang.php":

74 | 75 |
class Lang extends Fuel\Core\Lang {}
76 | 77 |

But classes that have the same name as core classes are ignored by default. To make the Autoloader recognize 78 | your replacement you need to register it in the application bootstrap file. Search for the lines below:

79 | 80 |
Autoloader::add_classes(array(
 81 | 	// Add classes you want to override here
 82 | 	// Example: 'View' => APPPATH.'classes/view.php',
 83 | ));
84 | 85 |

As is explained in the comments you need to add the new Lang class as follows:

86 | 87 |
Autoloader::add_classes(array(
 88 | 	// Add classes you want to override here
 89 | 	// Example: 'View' => APPPATH.'classes/view.php',
 90 | 	'Lang' => APPPATH.'classes/lang.php',
 91 | ));
92 | 93 |

After this the core class will have been replaced by your extension.

94 |

The core class will still be available when used with full namespace prefixed. With the above example of 95 | extending "Lang" you can still use the original by calling "Fuel\Core\Lang".

96 |
97 | 98 |
99 |

Extending the Core from packages

100 | 101 |

By adding your package as a core namespace the autoloader will attempt to load any class from your package 102 | before it attempts it from the core. You must register these classes with the Autoloader though in order 103 | for them to be detected (filesystem autoloader doesn't support aliasing to global). Below is an example for 104 | extending the View class.

105 | 106 |
Autoloader::add_core_namespace('Example');
107 | 
108 | Autoloader::add_classes(array(
109 | 	'Example\\View'  => __DIR__.'/classes/view.php',
110 | ));
111 |
112 | 113 |
114 |

Extension limitations

115 | 116 |

Most classes can be extended from both the app and packages but there are a few exceptions:

117 | 118 |
    119 |
  • Fuel
  • 120 |
  • Config
  • 121 |
  • Profiler
  • 122 |
  • Security
  • 123 |
  • Event
  • 124 |
  • Any class you use in your main app/config/config.php
  • 125 |
126 | 127 |

Autoloader

128 |

The Autoloader class is a special case, you can only extend it once as Autoloader and 129 | have it used. After extending it you have to require it manually in the app/bootstrap.php 130 | file after the original Fuel\Core\Autoloader, don't forget to remove the line that 131 | aliases the core class to global.

132 |
133 | 134 |
135 | 136 | 141 |
142 | 143 | 144 | -------------------------------------------------------------------------------- /packages/email/usage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Usage - Email Package - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 | 47 |

Using the Email package

48 | 49 |

The email package needs only 3 things from you in order to start sending emails.

50 | 51 |
    52 |
  1. An address to 'send from'.
  2. 53 |
  3. An address to send to.
  4. 54 |
  5. And last but not least, the message
  6. 55 |
56 | 57 |

Let's send mails.

58 | 59 |
// Create an instance
 60 | $email = Email::forge();
 61 | 
 62 | // Set the from address
 63 | $email->from('my@email.me', 'My Name');
 64 | 
 65 | // Set the to address
 66 | $email->to('receiver@elsewhere.co.uk', 'Johny Squid');
 67 | 
 68 | // Set a subject
 69 | $email->subject('This is the subject');
 70 | 
 71 | // Set multiple to addresses
 72 | 
 73 | $email->to(array(
 74 | 	'example@mail.com',
 75 | 	'another@mail.com' => 'With a Name',
 76 | ));
 77 | 
 78 | // And set the body.
 79 | $email->body('This is my message');
 80 | 
81 | 82 |

At this point we're ready to start sending the mail.

83 | 84 |

Exceptions

85 | 86 |

When sending a mail. You can encounter 2 exception types.

87 | 88 | 92 | 93 |

The example blow shows you how to handle those exceptions.

94 | 95 |
try
 96 | {
 97 | 	$email->send();
 98 | }
 99 | catch(\EmailValidationFailedException $e)
100 | {
101 | 	// The validation failed
102 | }
103 | catch(\EmailSendingFailedException $e)
104 | {
105 | 	// The driver could not send the email
106 | }
107 | 108 |

HTML mails.

109 | 110 |

Sending HTML mail is not very different from sending normal mails:

111 | 112 |
// Set a html body message
113 | $email->html_body(\View::forge('email/template', $email_data));
114 | 
115 | /** By default this will also generate an alt body from the html,
116 | 	and attach any inline files (not paths like http://...)       **/
117 | 
118 | // Set an alt body, this is optional.
119 | $email->alt_body('This is my alt body, for non-html viewers.');
120 | 121 |

Attachments

122 | 123 |

124 | The Email package supports two kinds of attachments: normal (attachment), and inline. Use an inline attachment if 125 | you want to use in inside the mail. You might, for instance, want to have a graphic in your mail, and you want people to 126 | that image offline also. Some clients don't cache that, and yes that's dumb. But it's the interwebs and stuff like that happens. 127 |

128 | 129 |
// Add an attachment
130 | $email->attach(DOCROOT.'dir/my_img.png');
131 | 
132 | // Add an inline attachment
133 | // Add a cid here to point to the html
134 | $email->attach(DOCROOT.'dir/my_img.png', true, 'cid:my_conten_id');
135 | 
136 | 137 |

You can also add string attachments:

138 | 139 |
$contents = file_get_contents($my_file);
140 | $email->string_attach($contents, $filename);
141 | 	
142 | 143 |

144 | By default html images are auto included, but it only includes local files. 145 | Look at the following html to see how it works. 146 |

147 | 148 |
<!-- This is included -->
149 | <img src="path/to/my/file.png" />
150 | 
151 | <!-- This is not included -->
152 | <img src="http://remote_host/file.jpeg" />
153 | 
154 | <!-- This is not included -->
155 | <img src="cid:my_conten_id" />
156 | 	
157 | 158 |

The last tag you saw (with the cid:) is also not included. In this situation the email expects you to attach that file yourself using an inline attachment.

159 | 160 |

Priotity

161 | 162 |

163 | Alter a mail's priority by using the priority method. 164 |

165 | 166 |
$email->priority(\Email::P_HIGH);
167 | 168 |
169 | 170 | 175 |
176 | 177 | 178 | -------------------------------------------------------------------------------- /packages/auth/simpleauth/acl.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Acl - SimpleAuth - Auth Package - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 |

SimpleAuth Acl

47 | 48 |

49 | As said in the introduction of the Auth package, an authentication system comes with 50 | three different drivers, each dealing with a part of the system. 51 |

52 |

53 | The SimpleAuth acl driver stores is role driven, and stores it's acl definitions in the simpleauth configuration file. 54 | It provides the logic for checking if a user has access to a named ACL. 55 |

56 | 57 |

Configuration

58 | 59 |

60 | The SimpleAuth acl driver stores it's group definitions in the simpleauth configuration file. The acls are defined as a set of 61 | access criteria linked to a specific role. It is defined as a multi-dimensional array, which must have the following structure: 62 |

63 | 64 |
array(
 65 | 	<role> => array(			// where <role> is the name of the role you're defining the ACL for
 66 | 		<location> => array(		// where <location> is what you're specifying the ACL for
 67 | 			'right', 'otherright'	// the specific rights for this location
 68 | 	),
 69 | ),
70 |

71 | You can specify as many locations as you need, and every location can have as many rights as needed. The simpleauth config 72 | file supplied with the Auth package contains some examples that you can use. 73 |

74 |

75 | You can use the system defined role "#" to specify default rights that will be set for every user, and which is commonly used 76 | to define the public rights to your application. For example, if everyone is allowed to read blog posts and their comments, 77 | you could define: 78 |

79 |
// default role for all users
 80 | '#' => array(
 81 | 	'blog' => array('read'),		// read access to 'blog'
 82 | 	'comments' => array('read'),	// read access to 'comments'
 83 | ),
84 |

85 | There are also two specific location definitions available for you to use. One that will simply deny all access, and one that 86 | will allow all access. You the last one with care! 87 |

88 |
// special role definitions
 89 | 'banned' => false,	// deny all access to users having the role 'banned'
 90 | 'administators' => true	// allow all access to users having the 'administrator' role
91 | 92 |

Class methods

93 | 94 |
95 |

has_access($condition)

96 |

The has_access method allows you to check if the current logged-in user has access to a specific location with specific rights.

97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 147 | 148 | 149 |
StaticNo
Parameters 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 |
ParamDefaultDescription
$conditionrequiredThe access condition you want to check
118 |
Returnsboolean. true if the user has access, or false if not.
Example 127 |
// check if the user has access to read blog posts
128 | if (Auth::has_access('blog.read'))
129 | {
130 | 	// yes, the user has access
131 | }
132 | 
133 | // if you have multiple instances, use the instance to call this method.
134 | // you can also check for multiple rights in one go
135 | if (Auth::instance('simpleauth')->has_access('blog.[read,write,delete]'))
136 | {
137 | 	// yes, the user has access and may read, write and delete
138 | }
139 | 
140 | // you can also specify the rights to check as an array
141 | if (Auth::has_access(array('blog' => array('read'), 'comments' => array('read')))
142 | {
143 | 	// yes, the user has access to read blogs and comments
144 | }
145 | 
146 |
150 |
151 | 152 |
153 | 154 | 159 |
160 | 161 | 162 | -------------------------------------------------------------------------------- /installation/instructions.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | Instruction - Installation - FuelPHP Documentation 14 | 15 | 16 |
17 | 39 | 40 |
41 |
42 |
43 |
44 | 45 |
46 | 47 |
Choose One: Command Line Installation | Manual Installation
48 |
49 |

Command Line Installation

50 |

This currently only works on *nix systems (Linux, OS X, Unix, etc).

51 |

Our quick installer is a stripped down interface for the Oil package. It allows you to create a new project with one command. You will also no longer need to use 'php' in your oil commands.

52 | 53 |

To install the quick installer, simply open up a shell and run the following command:

54 | 55 |
$ curl get.fuelphp.com/oil | sh
56 | 57 |

This will ask for your password, as it installs the script to /usr/bin.

58 | 59 |

Now you can just use 'oil' instead of 'php oil' in your projects.

60 | 61 |

To create a new project simply run:

62 | 63 |
$ oil create <project_name>
64 | 65 |

This will create a folder in the directory you are in with the project name you gave. It will then clone the repository and all submodules into that directory.

66 | 67 |

Note: This will also run $ oil refine install, which makes the necessary directories writable.

68 | 69 |

Manual Installation Instructions

70 | 71 |

This will create the default installation of the Fuel framework on your web server.

72 | 73 |
    74 |
  1. Download the Fuel Framework
  2. 75 |
  3. Unzip/Extract the download
  4. 76 |
  5. Move the files to your server 77 |
      78 |
    • Note the public directory in the source equals your web server's public document directory i.e. 79 | public_html, public, htdocs, etc. Move its contents to there or a subdirectory of the webroot 80 | where you want to use Fuel.
    • 81 |
    • Placing the fuel directory outside of the public document directory is encouraged for security 82 | reasons.
    • 83 |
    • Edit the paths in index.php to point to your app, core & packages directories.
    • 84 |
    85 |
    /
     86 |   fuel/
     87 |     app/
     88 |     core/
     89 |     packages/
     90 |   public/
     91 |     .htaccess
     92 |     assets/
     93 |     index.php
     94 |   oil
     95 | 
    96 |
  6. 97 |
  7. 98 | Set permissions on writable folders manually, or run: 99 |
    $ php oil refine install
    100 | 	Made writable: APPPATH/cache
    101 | 	Made writable: APPPATH/logs
    102 | 	Made writable: APPPATH/tmp
    103 | 	Made writable: APPPATH/config
    104 | 
    105 | 
    106 |
  8. 107 |
108 | 109 |

Configuration

110 | 111 |

The main configuration can be found at app/config/config.php. Edit it to your liking.

112 | 113 |

Install inside the document root

114 | 115 |

As explained in point 3, for security reasons it is strongly advised NOT to install Fuel inside your webserver's document root.

116 |

117 | However, there are cases where you would like to do that, for example for a (local) development environment where Apache's dynamic mass virtual hosting module 118 | is used to quickly setup new development environments without the need to restart the webserver. 119 |

120 |

In that case, you need an additional .htaccess file that you need to place in your document root, which will redirect requests to the site root to your public folder, and also modifies the rewrites to include the public folder:

121 |

122 | <IfModule mod_rewrite.c>
123 | 	RewriteEngine on
124 | 
125 | 	RewriteBase /public
126 | 
127 | 	RewriteRule ^(/)?$ index.php/$1 [L]
128 | 
129 | 	RewriteCond %{REQUEST_FILENAME} !-f
130 | 	RewriteCond %{REQUEST_FILENAME} !-d
131 | 
132 | 	RewriteRule ^(.*)$ index.php/$1 [L]
133 | </IfModule>
134 | 
135 | 
136 | 137 |

Setting the Environment

138 | 139 |

140 | By default, the environment is set to Development mode. Fuel uses the environment to define which database settings to use, but you can use it for other things. 141 |

142 |

143 | To set the environment, drop the following line into your .htaccess file. 144 |

145 |
SetEnv FUEL_ENV production
146 |

147 | Available options are detailed in the Class constants of the Fuel Class. 148 |

149 | 150 |
151 | 152 | 157 |
158 | 159 | 160 | -------------------------------------------------------------------------------- /classes/database/qb_delete.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 13 | 14 | Query Builder Delete - Classes - FuelPHP Documentation 15 | 16 | 17 |
18 | 40 | 41 |
42 |
43 |
44 |
45 | 46 |
47 | 48 |

Query_Builder_Delete class

49 | 50 |

51 | (extends Query_Builder_Where) 52 |

53 | 54 |

55 | The Query_Builder_Delete class handles all the delete operations for the query building process. It extends the 56 | Query_Builder_Where class, so all the methods are inherited. 57 |

58 | 59 |

Methods

60 | 61 |
62 |

table($table)

63 |

The table method sets/changes the table to delete from.

64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 105 | 106 | 107 |
StaticNo
Parameters 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 |
ParamTypeDefaultDescription
$tablestringrequiredthe table name
87 |
ReturnsReturns the current instance.
Example 96 |
// prepare an update statement
 97 | $query = DB::delete('users');
 98 | 
 99 | // Set the table to delete from
100 | $query->table('admins');
101 | 
102 | // DELETE `admins` ...
103 | 
104 |
108 |
109 | 110 |
111 |

compile(\Database_Connection$db)

112 |

The compile method returns the delete SQL query as a string.

113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 160 | 161 | 162 |
StaticNo
Parameters 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 |
ParamTypeDefaultDescription
$dbobjectrequiredA database connection
136 |
ReturnsReturns the SQL query as a string.
Example 145 |
// prepare an update statement
146 | $query = DB::delete('users');
147 | 
148 | // Set a where statement
149 | $query->where('looks', 'like', '%spammer%');
150 | 
151 | // Get the database connection
152 | $connection = Database_Connection::instance();
153 | 
154 | // Get the sql query
155 | $sql = $query->compile($connection);
156 | 
157 | // DELETE FROM `users` WHERE `looks` LIKE "%spammer%"
158 | 
159 |
163 |
164 | 165 |
166 |

reset()

167 |

The reset method resets all values of the current instance.

168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 208 | 209 | 210 |
StaticNo
Parameters 177 | None 178 |
ReturnsReturns the current instance.
Example 187 |
// prepare an update statement
188 | $query = DB:delete('users');
189 | 
190 | // Set a where statement
191 | $query->where('it_look', 'ok to me');
192 | 
193 | // Reset it
194 | $query->reset();
195 | 
196 | // Just an other where statement
197 | $query->where('looks', 'like', '%bad mister%');
198 | 
199 | // Get the database connection
200 | $connection = Database_Connection::instance();
201 | 
202 | // Get the sql query
203 | $sql = $query->compile($connection);
204 | 
205 | // DELETE FROM `users` WHERE `looks` LIKE "%bad mister%"
206 | 
207 |
211 |
212 | 213 |
214 | 215 | 220 |
221 | 222 | 223 | -------------------------------------------------------------------------------- /classes/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 13 | 14 | Package - Classes - FuelPHP Documentation 15 | 16 | 17 |
18 | 40 | 41 |
42 |
43 |
44 |
45 | 46 |
47 | 48 |

Package Class

49 | 50 |

The Package class allows you to easily load, unload, check if a package is loaded, or get all packages loaded.

51 | 52 |
53 |

load($package, $path = null)

54 |

The load method allows you to load one or more packages at runtime. If the package cannot be found a PackageNotFoundException will be thrown.

55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 103 | 104 | 105 |
StaticYes
Parameters 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 |
ParamDefaultDescription
$packagerequiredName of the package to be loaded, or an array of packages and package paths.
$pathPKGPATHPath to the folder in which the package is installed.
81 |
Returnsvoid
Example 90 |
// load the orm package
 91 | Package::load('orm');
 92 | 
 93 | // load the parser package from a specific directory
 94 | Package::load('parser', '/path/to/packages/dir/');
 95 | 
 96 | // load multiple packages from a single package installation
 97 | Package::load( array('First' => PKGPATH.'my'.DS.'first'.DS, 'Last' => PKGPATH.'my'.DS.'last'.DS) );
 98 | 
 99 | // load the non-existent package
100 | Package::load('awesome'); // Throws a PackageNotFoundException
101 | 
102 |
106 |
107 | 108 |
109 |

unload($package)

110 |

The unload method allows you to unload a package at runtime.

111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 145 | 146 | 147 |
StaticYes
Parameters 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 |
ParamDefaultDescription
$packagerequiredName of the package to be unloaded.
132 |
Returnsvoid
Example 141 |
// unload the orm package
142 | Package::unload('orm');
143 | 
144 |
148 |
149 | 150 |
151 |

loaded($package = null)

152 |

The loaded method allows you to check if a package is currently loaded. If no package name is given then all loaded packages are returned.

153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 197 | 198 | 199 |
StaticYes
Parameters 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 |
ParamDefaultDescription
$packagenullName of the package to be checked.
174 |
Returnsbool|array
Example 183 |
// Check if the orm package is loaded
184 | $loaded = Package::loaded('orm');
185 | 
186 | // Get all loaded packages
187 | $loaded = Package::loaded();
188 | /*
189 | Returns something like:
190 | array(
191 |     'orm' => '/path/to/orm',
192 |     'parser' => '/path/to/parser',
193 | )
194 | */
195 | 
196 |
200 |
201 | 202 |
203 | 204 | 209 |
210 | 211 | 212 | --------------------------------------------------------------------------------