silex starter

Overview

SilexStarter is starter application built by extending Silex micro framework. Built with purpose for rapid prototyping, it can generate clean and well organized code just in few minutes.

With modular architecture in mind, you can easily add or remove module, generate module scaffolding, install module via composer, or just drop module package in app/modules directory, and you are ready to go.

Installation

SilexStarter can be installed using composer, or clone directly from github repository and run composer install. Currently, SilexStarter has no stable version yet, as we are waiting for your feedback 🙂

Installation via composer can be done with following command:

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

Wait for composer downloading all required dependencies and generating autoload configuration, when it finished, we can start initializing our application with single step as SilexStarter utilized with console tool to help us do repeated task in view commands.

cd target_dir
./xpress app:init

It will guide you to configure the database, publishing assets, migrating database structure, and add default user (default user is ‘admin@domain.com’ and password is ‘password’).

Prototyping

As SilexStarter is built for rapid prototyping, it utilized with several commands like scaffolding generator command to help you generate basic structure based on repository pattern, and module creator command to help you generate basic module structure.

Creating First Module

First thing first, SilexStarter is built with modular architecture, we treat and organize everything as module, so let’s create our first module with the following simple command

./xpress module:create client-manager

It will create directory structure inside app/modules and generate basic module provider class with some basic configuration. It also create menu configuration, so dashboard module can list module menu in it’s sidebar.

Once you finished building your module, you can take out the module out of app/modules directory and build composer package independently, so it can be published on packagist.

Creating First Scaffolding

Once the module is generated, it is time to scaffold our module’s feature set. It is as simple as other command

./xpress scaffold client -m client-manager -d ajax -f 'id:increments|name:string|company:string|phone:string|email:string|address:text' --migrate

Its scaffold command for generating basic scaffolding for client feature, scaffold command accept several arguments and options, on the example above, it can be broken down as below

  • ./xpress This is the SilexStarter console application
  • scaffold This is the scaffold command
  • client The entity name
  • -m client-manager The target module, so the scaffolding will be generated into client-manager module, it can be written as --module=module-name
  • -d ajax This scaffolding mode, it will generate scaffolding based on ajax template, it accept standard (default), api, and ajax
  • -f '...field-definition..' This is the field definition, can be written as field_name:field_type:option_if_exists|field_name:field_type
  • --migrate This tell the command to migrate the database migration after the scaffolding is generated

Now you can see your module menu appear in the dashboard sidebar, and start adding new client into database.

Detailed documentation is still work in progress 🙂