GithubHelp home page GithubHelp logo

silex-starter's Introduction

silex-starter

Silex starter project.

Composer

run composer install in the app root folder to install dependencies

Database

Migrations

phinx

run php vendor/bin/phinx in the app root folder for commands

// TODO: Move to doctrine migrations

Models and Queries

// TODO

Routes and Controllers

Add your route definitions to app/app.php. There is a home route there for your reference:

$app->get('/', 'SilexStarter\Controller\HomeController::index')
    ->bind('home');

This route will direct the uri / to the index method of the 'SilexStarter\Controller\HomeController' class. The bind command will allow you to reference this route in your templates like this: {{ path('home') }}.

Check out the official docs for more info.

Caching

If you want to cache a response, simply add the Cache-Control header to something like s-maxage=3600, public. The standard setup will use the cache folder to store response and serve responses from there without having to bootstrap the app.

Unit Tests

Put your phpunit tests in the tests/ folder. Extend the \SilexStarter\Test\AbstractTestCase class in order to have access to things like the web crawler. Here's an example:

use \SilexStarter\Test\AbstractTestCase;

class SomeTest extends AbstractTestCase
{
    public function testSomething()
    {
        $client = $this->createClient();
        $crawler = $client->request('GET', '/');
    
        $this->assertTrue($client->getResponse()->isOk());
        $this->assertCount(1, $crawler->filter('h1:contains("Hello World")'));
    }
}

Check out the official documentation for more info.

Logging

The logging service is available by using $app['monolog']. The log files reside in app/logs/. Here are some examples:

$app['monolog']->info('script started');
$app['monolog']->error('Failed to call function', ['key', $value]);

silex-starter's People

Contributors

dwolfhub avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.