2017 © Pedro Peláez
 

library silexstarter

A starter application based on Silex framework

image

xsanisty/silexstarter

A starter application based on Silex framework

  • Monday, February 20, 2017
  • by xsanisty
  • Repository
  • 3 Watchers
  • 12 Stars
  • 96 Installations
  • CSS
  • 0 Dependents
  • 0 Suggesters
  • 6 Forks
  • 1 Open issues
  • 2 Versions
  • 1 % Grown

The README.md

[Build Status] (https://scrutinizer-ci.com/g/xsanisty/SilexStarter/build-status/develop) [Scrutinizer Code Quality] (https://scrutinizer-ci.com/g/xsanisty/SilexStarter/?branch=develop) [Code Coverage] (https://scrutinizer-ci.com/g/xsanisty/SilexStarter/?branch=develop) [SensioLabsInsight] (https://insight.sensiolabs.com/projects/a30a66f9-8110-40c5-8a35-f3c1697dde55), (*1)

screenshot, (*2)

SilexStarter

SilexStarter is a starter application built on the top of Silex framework, Laravel's Eloquent, Cartalyst Sentry, and some other third party and built in components. SilexStarter aim to help building simple application faster, it built with MVC and modular approach in mind, and comes with some basic admin module, including user manager, and module manager., (*3)

Installation

For now, the installable branch is only develop branch, you can easily install it using composer by using following command, (*4)

composer create-project xsanisty/silexstarter target_dir dev-develop -s dev

once composer install is completed, you can initialize the app using following command, (*5)

$cd target_dir
$./xpress app:init

Module can be developed directly inside the app/modules directory and create module on its own namespace or build it as separate composer package, module can be enabled or disabled by registering it in app/config/modules.php, (*6)

Route

file : app/routes.php Route configuration can be created like normal Silex route, or using route builder using similar syntax like Laravel's route., (*7)

Silex routing style, (*8)

/* the application instance is available as $app in context of route.php */

$app->get('/page', function(){
    return 'I am in a page';
});

$app->post('/save', function(){
   return 'Ok, all data is saved!';
});

/* grouping */
$app->group('prefix', function() use ($app) {
    $app->group('page', function() use ($app) {
        $app->get('index', function(){
            return 'I am in prefix/page/index';
        });
    });
});

/* resourceful controller */
$app->resource('prefix', 'SomeController');

/* route controller */
$app->controller('prefix', 'SomeController');

Laravel routing style, (*9)

/* route can be built using the Route static proxy */

Route::get('/page', function(){
    return 'I am in a page';
});

Route::post('/save', function(){
   return 'Ok, all data is saved!';
});

/* grouping */
Route::group('prefix', function() {
    Route::group('page', function() {
        Route::get('index', function(){
            return 'I am in prefix/page/index';
        });
    });
});

/* resourceful controller */
Route::resource('prefix', 'SomeController');

/* route controller */
Route::controller('prefix', 'SomeController');

Controller

file: app/controllers/*, (*10)

Controller basically can be any classes that reside in controllers folder, it will be registered as service when enabled, and will be properly instantiated when needed, with all dependency injected., (*11)

Assume we have PostRepository and CommentRepository, we should register it first before it can be properly injected into controller., (*12)

file: app/services/RepositoryServiceProvider.php, (*13)

<?php

use Silex\Application;
use Silex\ServiceProviderInterface;

class RepositoryServiceProvider implements ServiceProviderInterface
{
    public function register(Application $app)
    {
        $app['PostRepository'] = $app->share(function (Application $app) {
            return new PostRepository
        });

        $app['CommentRepository'] = $app->share(function (Application $app) {
            return new PostRepository
        });
    }

    public function boot(Application $app)
    {

    }
}

file: app/config/services.php, (*14)

<?php

return [
    'common' => [
        'RepositoryServiceProvider',
    ]
]

file: app/controllers/PostController.php, (*15)

<?php

class PostController{

    protected $postRepo;
    protected $commentRepo;

    public function __construct(PostRepository $postRepo, CommentRepository $commentRepo)
    {
        $this->postRepo = $postRepo;
        $this->commentRepo = $commentRepo;
    }

    public function index(){
        return Response::view('post/index', $this->postRepo->all());
    }
}

and now, we should able to create route map to this controller, (*16)

Route::get('/post', 'PostController:index');

Model

file: app/models/*, (*17)

SilexStarter use Eloquent ORM as database abstraction layer, so you can extends it to create model classJeyac. The configuration of the database can be found in app/config/database.php, (*18)

<?php

class Post extends Model{
    protected $table = 'posts';

    public function comments(){
        return $this->hasMany('Comment');
    }
}

View

file: app/views/*, (*19)

Middleware

file: app/middlewares.php, (*20)

Service Provider

file: src/Providers/*, (*21)

Module

file: app/modules/*, (*22)

Register module

file: app/config/modules.php, (*23)

Module Provider

file: app/modules/**/ModuleProvider.php, (*24)

Asset

The Versions

20/02 2017

dev-develop

dev-develop

A starter application based on Silex framework

  Sources   Download

MIT

The Requires

  • xsanisty/silexstarter-core dev-develop
  • xsanisty/silexstarter-dashboard dev-develop
  • xsanisty/silexstarter-datatable dev-develop
  • xsanisty/silexstarter-usermanager dev-develop
  • xsanisty/silexstarter-modulemanager dev-develop

 

The Development Requires

by Xsanisty Dev Team

framework twig eloquent mvc silex silex starter silex dashboard

20/02 2017

dev-master

9999999-dev

A starter application based on Silex framework

  Sources   Download

MIT

The Requires

  • xsanisty/silexstarter-core dev-develop
  • xsanisty/silexstarter-dashboard dev-develop
  • xsanisty/silexstarter-datatable dev-develop
  • xsanisty/silexstarter-usermanager dev-develop
  • xsanisty/silexstarter-modulemanager dev-develop

 

The Development Requires

by Xsanisty Dev Team

framework twig eloquent mvc silex silex starter silex dashboard