mareksokol/silex-bootstrap

Bootstrap for Silex based API

2.1.0 2017-12-03 03:52 UTC

This package is not auto-updated.

Last update: 2024-04-24 06:26:32 UTC


README

Build Status

Silex-bootstrap is an already setup Silex project dedicated for lightweight, RESTful APIs.

Installation

To start a new project, run:

composer create-project mareksokol/silex-bootstrap <target-dir>

You need also to create config file in root directory:

cp config.php.dist config.php

Directory structure

The directory structure is the following

bin/
src/
  Controller/
  Entity/
    Migrations/
    Repository/
  Service/
    Provider/
storage/
    logs/
    proxies/
tests/
web/

bin/ place for all executables, eg. command line tool

src/ is the root of application, contains application files: controllers, entities, migrations, repositories, services, providers and bootstrap file

storage/ all static files, including application logs

test/ contains unit tests

web/ contains everything which is exposed - HTTP server should be configured to point this place as root

Usage

Configuration

All configuration should be places in config.php file. To define new configuration parameters need to add definition in App\Service\Provider\ConfigServiceProvider::$config.

Controllers

Controllers should inherit from App\Controller\AbstractController - this class implements several helper methods to simplify output from API. To register new controller need to add declaration in App\Bootstrap::loadControllers().

Routes

Routes are defined in App\Bootstrap::routes().

Services

Services are registered via service providers in App\Bootstrap::loadServices(). Custom service providers should be placed in App\Service\Provider namespace.

Database

All database mechanism is based on Doctrine2 framework. There is dedicated namespace App\Entity for all doctrine classes (entities, repositories: App\Entity\Repository and migrations: App\Entity\Migrations).