https://github.com/maniator/smallfry
SmallFry PHP Framework
https://github.com/maniator/smallfry
Last synced: over 1 year ago
JSON representation
SmallFry PHP Framework
- Host: GitHub
- URL: https://github.com/maniator/smallfry
- Owner: maniator
- Created: 2011-09-28T15:12:33.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2013-08-28T12:54:43.000Z (almost 13 years ago)
- Last Synced: 2025-03-17T01:04:45.940Z (over 1 year ago)
- Language: PHP
- Homepage: http://maniator.github.com/SmallFry/
- Size: 715 KB
- Stars: 7
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
Awesome Lists containing this project
README
SmallFry PHP Library
==
###Configuration:
Put all configuration into in the `/smallFry/config/config.ini` file and set ROOTs in the `AppConfig.php` file
To get something from the configuration you can do when inside a Model or Controller:
$this->CONFIG->get('CONFIG_VARIABLE');
###Controller:
Put all controllers in the `/controller` folder
An example of a controller called `Test`:
namespace SmallFry\Controller;
class TestController extends \SmallFry\lib\AppController {
protected $name = 'Test';
//pages go here
function index(){
$this->template->set('test', 'hello there');
}
}
###Views:
Put all views in the `/view` folder with a directory for every different controller:
The view for the `Test` controller (located in `/view/test/index.stp`):
echo $test;
This will display to the user when they go to `http://localhost/index.php/Test/index`:
hello there
###MySQL and Models:
Inside of the controller class you can do mysql queries
The object to use is `$this->ModelName` which is the model that handles all database queries.
For example (a raw mysql example):
namespace SmallFry\Controller;
class TestController extends \SmallFry\lib\AppController {
protected $name = 'Test';
function index(){
$rows = array();
$results = $this->Test->queryit('SELECT * FROM TABLE'); // one way to use a model to query the database
foreach($results as $row) {
$rows[] = $row;
}
$this->template->set('rows', $rows); //for use in the view
}
}
In order to use the following example you have to create a `Model` that goes with the current controller in the `model` directory:
namespace SmallFry\Model;
class Test extends \SmallFry\lib\AppModel {
}
This model will query from the `tests` table if one is **not** doing raw MySQL statements.
This example selects all records from the `tests` table in the database:
namespace SmallFry\Controller;
class TestController extends \SmallFry\lib\AppController {
protected $name = 'Test';
function index(){
$rows = array();
$results = $this->Test->selectAll();
foreach($results as $row) {
$rows[] = $row;
}
$this->template->set('rows', $rows); //for use in the view
}
}