Recommend this page to a friend! |
Download .zip |
Info | Documentation | Screenshots | View files (98) | Download .zip | Reputation | Support forum (1) | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2024-06-15 (Yesterday) | 59% | Total: 599 | All time: 5,196 This week: 82 |
Version | License | PHP version | Categories | |||
slim-starter 1.0.11 | MIT/X Consortium ... | 5.3 | PHP 5, Libraries, Design Patterns |
Description | Author | |
This package can be used to Build MVC Web applications based on the Slim framework. |
SlimStarter is a bootstrap application built with Slim Framework in MVC architecture, with Laravel's Eloquent as database provider (Model) and Twig as template engine (View).
Additional package is Sentry as authentication provider and Slim-facade which provide easy access to underlying Slim API with static interface like Laravel syntax (built based on Laravel's Facade).
You can test SlimStarter in live site by visiting here : (shared hosting) http://slimstarter.xsanisty.com (pagodabox) http://slimstarter.gopagoda.com
with username `
admin@admin.com`
and password `
password`
.
> You can now install SlimStarter on pagodabox via App Cafe https://pagodabox.com/cafe/ikhsan017/slimstarter
You can manually install SlimStarter by cloning this repo or download the zip file from this repo, and run `
composer install`
.
$git clone https://github.com/xsanisty/SlimStarter.git .
$composer install
`
composer create-project`
Alternatively, you can use `
composer create-project`
to install SlimStarter without downloading zip or cloning this repo.
composer create-project xsanisty/slim-starter --stability="dev"
After composer finished install the dependencies, you need to change file and folder permission.
chmod -R 777 app/storage/
chmod 666 app/config/database.php
You can now access the installer by pointing install.php in your browser
http://localhost/path/to/SlimStarter/public/install.php
Configuration file of SlimStarter located in `
app/config`
, edit the database.php, cookie.php and other to match your need
Routing configuration is located in `
app/routes.php`
, it use Route facade to access underlying Slim router.
If you prefer the 'Slim' way, you can use $app to access Slim instance
Route to closure
Route::get('/', function(){
View::display('welcome.twig');
});
/ the Slim way */
$app->get('/', function() use ($app){
$app->view->display('welcome.twig');
});
Route to controller method
/ get method */
Route::get('/', 'SomeController:someMethod');
/ post method */
Route::post('/post', 'PostController:create');
/ put method */
Route::put('/post/:id', 'PostController:update');
/ delete method */
Route::delete('/post/:id', 'PostController:destroy');
Route Middleware
/ route middleware */
Route::get('/admin', function(){
//route middleware to check user login or redirect
}, 'AdminController:index');
Route group
/ Route group to book resource */
Route::group('/book', function(){
Route::get('/', 'BookController:index'); // GET /book
Route::post('/', 'BookController:store'); // POST /book
Route::get('/create', 'BookController:create'); // Create form of /book
Route::get('/:id', 'BookController:show'); // GET /book/:id
Route::get('/:id/edit', 'BookController:edit'); // GET /book/:id/edit
Route::put('/:id', 'BookController:update'); // PUT /book/:id
Route::delete('/:id', 'BookController:destroy'); // DELETE /book/:id
});
Route Resource this will have same effect on route group above like Laravel Route::resource
/ Route to book resource */
Route::resource('/book', 'BookController');
RouteController
/ Route to book resource */
Route::controller('/book', 'BookController');
/
* GET /book will be mapped to BookController:getIndex
* POST /book will be mapped to BookController:postIndex
* [METHOD] /book/[path] will be mapped to BookController:methodPath
*/
Models are located in `
app/models`
directory, since Eloquent is used as database provider, you can write model like you
write model for Laravel, for complete documentation about eloquent, please refer to http://laravel.com/docs/eloquent
file : app/models/Book.php
class Book Extends Model{}
>Note: Eloquent has some limitations due to dependency to some Laravel's and Symfony's components which is not included,
such as `
remember()`
, `
paginate`
, and validation method, which is depend on `
Illuminate\Cache`
, `
Illuminate\Filesystem`
,
## Controller
Controllers are located in ```app/controllers``` directory, you may extends the BaseController to get access to predefined helper.
You can also place your controller in namespace to group your controller.
file : app/controllers/HomeController.php
Class HomeController extends BaseController{
public function welcome(){
$this->data['title'] = 'Some title';
View::display('welcome.twig', $this->data);
}
}
## Controller helper
### Get reference to Slim instance
You can access Slim instance inside your controller by accessing $app property
$this->app; //reference to Slim instance
### Loading javascript assets or CSS assets
SlimStarter shipped with default master template with js and css asset already in place, to load your own js or css file
you can use ```loadJs``` or ```loadCss``` , ```removeJs``` or ```removeCss``` to remove js or css, ```resetJs``` or ```resetCss```
to remove all queued js or css file.
/ * load local js file located in public/assets/js/application.js * by default, it will be placed in the last list, * to modify it, use position option in second parameter * array( * 'position' => 'last|first|after:file|before:file' * ) */ $this->loadJs('application.js', ['position' => 'after:jquery.js'])
/ * load external js file, eg: js in CDN * use location option in second parameter * array( * 'location' => 'internal|external' * ) */ $this->loadJs('http://code.jquery.com/jquery-1.11.0.min.js', ['location' => 'external']);
/ remove js file from the list */ $this->removeJs('user.js');
/ reset js queue, no js file will be loaded */ $this->resetJs();
/ load local css file located in public/assets/css/style.css */ $this->loadCss('style.css')
/ load external css file, eg: js in CDN */ $this->loadCss('//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css', ['location' => 'external']);
/
### Publish PHP variable to javascript
You can also publish PHP variable to make it accessible via javascript (must extends master.twig)
/ publish the variable */ $this->publish('user', User::find(1)->toArray());
/ remove the variable */ $this->unpublish('user');
the user variable will be accessible in 'global' namespace
console.log(global.user);
### Default variable available in template
## View
Views file are located in ```app/views``` directory in twig format, there is master.twig with 'body' block as default master template
shipped with SlimStarer that will provide default access to published js variable.
For detailed Twig documentation, please refer to http://twig.sensiolabs.org/documentation
file : app/views/welcome.twig
{% extends 'master.twig' %} {% block body %}
Welcome to SlimStarter
{% endblock %}
### Rendering view inside controller
If your controller extends the BaseController class, you will have access to $data property which will be the placeholder for all
view's data.
View::display('welcome.twig', $this->data);
## Hooks and Middlewares
You can still hook the Slim event, or registering Middleware to Slim instance in ```app/bootstrap/app.php```,
Slim instance is accessible in ```$app``` variable.
$app->hook('slim.before.route', function(){
//do your hook
});
$app->add(new SomeActionMiddleware());
You can write your own middleware class in ```app/middlewares``` directory.
file : app/middlewares/SomeActionMiddleware.php
class SomeActionMiddleware extends Middleware {
public function call()
{
// Get reference to application
$app = $this->app;
// Run inner middleware and application
$this->next->call();
// do your stuff
}
}
In case autoloader cannot resolve your classes, do ```composer dump-autoload``` so composer can resolve your class location
Screenshots | ||
Files |
File | Role | Description | ||
---|---|---|---|---|
app (1 file, 6 directories) | ||||
public (3 files, 1 directory) | ||||
src (1 directory) | ||||
Boxfile | Data | Information file for deploying on pagodabox cloud server | ||
Boxfile.install | Data | Information file for deploying on pagodabox cloud server | ||
composer.json | Data | package dependency information | ||
LICENSE | Lic. | License file | ||
migrate.php | Example | script for migrating basic db | ||
README.md | Doc. | basic documentation file |
Files | / | app |
File | Role | Description | ||
---|---|---|---|---|
bootstrap (2 files) | ||||
config (6 files) | ||||
controllers (4 files, 1 directory) | ||||
models (1 file) | ||||
modules (1 directory) | ||||
views (2 files, 3 directories) | ||||
routes.php | Appl. | routing configuration |
Files | / | app | / | config |
File | Role | Description |
---|---|---|
aliases.php | Conf. | alias configuration |
cookies.php | Conf. | cookie configuration |
database.php | Conf. | database configuration |
sentry.php | Conf. | sentry authentication configuration |
slim.php | Conf. | Slim configuration |
twig.php | Conf. | twig configuration |
Files | / | app | / | controllers |
File | Role | Description | ||
---|---|---|---|---|
Admin (2 files) | ||||
BaseController.php | Appl. | Base controller | ||
DocController.php | Appl. | Documentation controller | ||
HomeController.php | Appl. | welcome page controller | ||
InstallController.php | Appl. | Installation controller |
Files | / | app | / | controllers | / | Admin |
File | Role | Description |
---|---|---|
AdminController.php | Appl. | Admin authentication Controller |
BaseController.php | Appl. | Admin Base controller |
Files | / | app | / | modules | / | UserGroup |
File | Role | Description | ||
---|---|---|---|---|
Controllers (2 files) | ||||
views (2 directories) | ||||
Initialize.php | Appl. | UserGroup module initializer |
Files | / | app | / | modules | / | UserGroup | / | Controllers |
File | Role | Description |
---|---|---|
GroupController.php | Appl. | Application script |
UserController.php | Class | Class source |
Files | / | app | / | modules | / | UserGroup | / | views | / | group |
File | Role | Description |
---|---|---|
index.twig | Data | Auxiliary data |
Files | / | app | / | modules | / | UserGroup | / | views | / | user |
File | Role | Description |
---|---|---|
edit.twig | Data | Auxiliary data |
form.twig | Data | Auxiliary data |
index.twig | Data | Auxiliary data |
Files | / | app | / | views |
File | Role | Description | ||
---|---|---|---|---|
admin (5 files) | ||||
docs (3 files) | ||||
install (2 files) | ||||
master.twig | Data | master template file | ||
welcome.twig | Data | sample template file |
Files | / | app | / | views | / | admin |
File | Role | Description |
---|---|---|
dashboard.twig | Data | base dashboard template |
index.twig | Data | Auxiliary data |
login.twig | Data | Auxiliary data |
sidebar.twig | Data | Auxiliary data |
topbar.twig | Data | Auxiliary data |
Files | / | app | / | views | / | docs |
File | Role | Description |
---|---|---|
index.twig | Data | Auxiliary data |
sidebar.twig | Data | Auxiliary data |
topbar.twig | Data | Auxiliary data |
Files | / | app | / | views | / | install |
File | Role | Description |
---|---|---|
configure_db.twig | Data | Auxiliary data |
finish.twig | Data | Auxiliary data |
Files | / | public |
File | Role | Description | ||
---|---|---|---|---|
assets (4 directories) | ||||
.htaccess | Data | apache rewrite script | ||
index.php | Appl. | front controller | ||
install.php | Appl. | install script |
Files | / | public | / | assets | / | css |
File | Role | Description | ||
---|---|---|---|---|
plugins (4 directories) | ||||
bootstrap.css | Data | Auxiliary data | ||
bootstrap.min.css | Data | Auxiliary data | ||
custom.css | Data | Auxiliary data | ||
font-awesome.css | Data | Auxiliary data | ||
font-awesome.min.css | Data | Auxiliary data | ||
sb-admin.css | Data | Auxiliary data |
Files | / | public | / | assets | / | css | / | plugins |
File | Role | Description | ||
---|---|---|---|---|
dataTables (1 file) | ||||
morris (1 file) | ||||
social-buttons (1 file) | ||||
timeline (1 file) |
Files | / | public | / | assets | / | css | / | plugins | / | dataTables |
File | Role | Description |
---|---|---|
dataTables.bootstrap.css | Data | Auxiliary data |
Files | / | public | / | assets | / | css | / | plugins | / | morris |
File | Role | Description |
---|---|---|
morris-0.4.3.min.css | Data | Auxiliary data |
Files | / | public | / | assets | / | css | / | plugins | / | timeline |
File | Role | Description |
---|---|---|
timeline.css | Data | Auxiliary data |
Files | / | public | / | assets | / | fonts |
File | Role | Description |
---|---|---|
fontawesome-webfont.eot | Data | Auxiliary data |
fontawesome-webfont.svg | Data | Auxiliary data |
fontawesome-webfont.ttf | Data | Auxiliary data |
fontawesome-webfont.woff | Data | Auxiliary data |
FontAwesome.otf | Data | Auxiliary data |
glyphicons-halflings-regular.eot | Data | Auxiliary data |
glyphicons-halflings-regular.svg | Data | Auxiliary data |
glyphicons-halflings-regular.ttf | Data | Auxiliary data |
glyphicons-halflings-regular.woff | Data | Auxiliary data |
Files | / | public | / | assets | / | images |
File | Role | Description |
---|---|---|
loader.gif | Icon | Icon image |
logo.png | Icon | Icon image |
Files | / | public | / | assets | / | js |
File | Role | Description | ||
---|---|---|---|---|
app (2 files) | ||||
demo (3 files) | ||||
plugins (4 directories) | ||||
bootstrap.js | Data | Auxiliary data | ||
bootstrap.min.js | Data | Auxiliary data | ||
jquery-1.10.2.js | Data | Auxiliary data | ||
sb-admin.js | Data | Auxiliary data |
Files | / | public | / | assets | / | js | / | app |
File | Role | Description |
---|---|---|
install.js | Data | Auxiliary data |
user.js | Data | Auxiliary data |
Files | / | public | / | assets | / | js | / | demo |
File | Role | Description |
---|---|---|
dashboard-demo.js | Data | Auxiliary data |
flot-demo.js | Data | Auxiliary data |
morris-demo.js | Data | Auxiliary data |
Files | / | public | / | assets | / | js | / | plugins |
File | Role | Description | ||
---|---|---|---|---|
dataTables (2 files) | ||||
flot (5 files) | ||||
metisMenu (1 file) | ||||
morris (2 files) |
Files | / | public | / | assets | / | js | / | plugins | / | dataTables |
File | Role | Description |
---|---|---|
dataTables.bootstrap.js | Data | Auxiliary data |
jquery.dataTables.js | Data | datatable js plugin |
Files | / | public | / | assets | / | js | / | plugins | / | flot |
File | Role | Description |
---|---|---|
excanvas.min.js | Data | excanvas for canvas ability in when not supported |
jquery.flot.js | Data | jquery plugin for graphing |
jquery.flot.pie.js | Data | support pie chart for flot |
jquery.flot.resize.js | Data | support resize chart for flot |
jquery.flot.tooltip.min.js | Data | support tooltip for flot |
Files | / | public | / | assets | / | js | / | plugins | / | metisMenu |
File | Role | Description |
---|---|---|
jquery.metisMenu.js | Data | menu effect for admin dashboard |
Files | / | public | / | assets | / | js | / | plugins | / | morris |
File | Role | Description |
---|---|---|
morris.js | Data | morris chart plugin |
raphael-2.1.0.min.js | Data | raphael plugin for morris |
Files | / | src | / | SlimStarter |
File | Role | Description | ||
---|---|---|---|---|
Facade (6 files) | ||||
Menu (3 files) | ||||
Module (3 files) | ||||
TwigExtension (1 file) | ||||
Bootstrap.php | Class | Application Bootstrapper class |
Files | / | src | / | SlimStarter | / | Facade |
File | Role | Description |
---|---|---|
DatabaseFacade.php | Class | Database static proxy class |
MenuManagerFacade.php | Class | Menu Manager static proxy class |
ModuleManagerFacade.php | Class | Modue Manager static proxy class |
ResponseFacade.php | Class | Response static proxy class |
RouteFacade.php | Class | Route static proxy class |
SentryFacade.php | Class | Sentry static proxy class |
Files | / | src | / | SlimStarter | / | Menu |
File | Role | Description |
---|---|---|
MenuCollection.php | Class | Menu collection to manage menu item |
MenuItem.php | Class | MenuItem class |
MenuManager.php | Class | Menu manager for rendering ang manage menu collection |
Files | / | src | / | SlimStarter | / | Module |
File | Role | Description |
---|---|---|
Initializer.php | Class | base modue initializer |
Manager.php | Class | module manager |
ModuleInterface.php | Class | Class source |
Files | / | src | / | SlimStarter | / | TwigExtension |
File | Role | Description |
---|---|---|
MenuRenderer.php | Class | Twig extension for rendering menu |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
98% |
|
|
User Ratings | ||||||||||||||||||||||||||||||
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.