Skip to content

Instantly share code, notes, and snippets.

@cybrown
Created July 14, 2013 16:24
Show Gist options
  • Select an option

  • Save cybrown/5994819 to your computer and use it in GitHub Desktop.

Select an option

Save cybrown/5994819 to your computer and use it in GitHub Desktop.
Basic testable Silex application with travis, phpunit, composer and gitignore files.
/composer.lock
/vendor
language: php
php:
- 5.5
- 5.4
- 5.3
before_script:
- composer install
script: vendor/bin/phpunit
<?php
// src/app.php
require_once __DIR__.'/../vendor/autoload.php';
$app = new Silex\Application();
$app->get('/', function () use ($app) {
return '<a href="/hello/world">Link to hello world</a>';
});
$app->get('/hello/{name}', function ($name) use ($app) {
return 'Hello '.$app->escape($name);
});
return $app;
{
"require": {
"silex/silex": "1.*"
},
"require-dev": {
"phpunit/phpunit": "*",
"symfony/browser-kit": "*"
},
"autoload": {
"psr-0": {"APP_NAMESPACE_HERE\\": "src/"}
}
}
<?php
// web/index.php
$app = require_once __DIR__ . '/../src/app.php';
$app->run();
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="NAME HERE !!! Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
#command line for php 5.4+ integrated server
php -S 127.0.0.1:8080 web/index.php -t web
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment