Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bjarneo/q
Q PHP Framework
https://github.com/bjarneo/q
Last synced: 3 days ago
JSON representation
Q PHP Framework
- Host: GitHub
- URL: https://github.com/bjarneo/q
- Owner: bjarneo
- License: mit
- Created: 2013-11-24T09:11:39.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2014-01-07T18:35:45.000Z (almost 11 years ago)
- Last Synced: 2024-04-15T02:09:39.016Z (7 months ago)
- Language: PHP
- Size: 430 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Q PHP Framework
=
http://q.codephun.com/This is not a RESTful framework. This framework is ment for small applications that only needs few pages.
Requires: Composer.###Install
```php
// Clone repository
git clone https://github.com/bjarneo/Q.git// Open Q directory
composer install// Or if you composer.phar file isn't placed in your bin directory (unix systems) use this command
php composer.phar install
```### Set up index.php file
```php
// Require composer's autoloader
require 'vendor/autoload.php';// Create new instance of Q
$app = new \Q\Q(array(
'mode' => 'development', // 'production' for no error messages
'view_path' => './app/View/' // Set view folder.
));
```### Append routes (paths)
```php
$app->route('/', function() {
echo 'Hello Q';
});
```### Run application
```php
// After last route you've created you must run you application
$app->run()
```### Render view
```php
$app->route('/hello', function() use ($app) {
$app->render('template.php');
});
```### Add data to templates
```php
$app->route('/hello', function() use($app) {
$data = array(
'greeting' => 'Hello Q!'
);// Now use echo $greeting in template.php
$app->render('template.php', $data);
});
```### How to use parameters
```php
// Add params as parameters in function
$app->route('/path', function($name, $age) {
printf("My name is: %s. I'm %s years old.", $name, $age);
});// Ex: domain.com/path/bjarneo/26
// Ouput: My name is: bjarneo. I'm 26 years old.
```