Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.
/ silex-base Public archive

Base framework that extends silex and adds some common components

License

Notifications You must be signed in to change notification settings

ronanchilvers/silex-base

Repository files navigation

Silex-Base

A silex skeleton project with ideas borrowed from fabpot's silex skeleton. I have rejigged the filesystem layout a bit, turned on and configured some core providers and added some third party providers.

Using this package

The easiest way to use this package is via composer like so:

composer create-project ronanchilvers/silex-base

Currently the project is not in packagist so you'll probably need to add the repository to your global ~/.composer/config.json file.

{
    "repositories": [
        {
            "type": "vcs",
            "url":  "https://github.com/ronanchilvers/silex-base.git"
        }
    ]
}

Then create a local config stub file bby changing into the working copy root and doing:

cp local.config.php.dist local.config.php

You should now have a project ready to run. To view the test page do:

composer serve

This will run the site in dev mode using the builtin php web server.

Filesystem Layout

Here's a description of the main components of the project and what they are.

  • app
    • config
      • app.php - the main configuration file for the app. Registers the main providers
      • console.php - the configuration file for the console tool
      • dev.php - configuration file for dev environment
      • prod.php - configuration file for the production environment
    • resources
      • js - javascript source files
      • sass - SASS source files with some default components
    • views - The application views. The Twig service provider is configured to look in here for its views.
      • error - Error handling templates
      • test - test controller templates. Can be removed.
  • bin
    • console - CLI console script
  • src - the php source code for the application, configured as PSR-4 in the App namespace
    • Controller - the application controllers. This directory is searched by the annotations service for routes
      • ErrorController.php - Standard error controller
      • TestController.php - Test controller. Can be removed.
    • Application.php - Base application subclass with some traits added
    • Controller.php - Base controller class with some useful shortcuts
  • var
    • cache - Cache directory for annotations, web profiler, etc
    • data - Data directory holding the base sqlite database by default
    • log - Default location for application logs
  • web
    • css - Default location for compiled CSS
    • js - Default location for compiled javascript
    • index.php - Production bootstrap
    • index_dev.php - Development bootstrap
  • deploy.php.dist - A sample deployment recipe for use with deployer
  • local.config.php.dist - A sample local config file
  • gulpfile.js - The default gulpfile recipe for the project

Configuration

For configuring arbitrary parameters for a specific deployment of your codebase you should use a local.config.php file which returns an array of config variables. This array is available on the $app object as $app['config']. The config file should not be stored in version control.

To add providers and configure the structure of the framework you should use the app/config/(app|dev|prod).php files. However these are not intended to allow per environment configuration such as different database connections, etc. That's the job of the local.config.php file.

Providers

The following providers are enabled by default:

Silex core / official providers

Third party providers

Frontend resources

The base project is configured to use gulp for compiling frontend resources stored in app/resources. We recommend using yarn instead of npm for a more pleasant experience all round. (You'll need nodejs installed to run this stuff at all - version 6.9.X seems to work). You can run it by doing:

yarn install
./node_modules/.bin/gulp