Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 2ce4e178da
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 152 lines (124 sloc) 3.897 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
#!/bin/bash

# Script that optimizes a Symfony2 standard distribution for raw performance benchmarks

# Get the Symfony2 standard edition
mkdir benchmark
cd benchmark
git clone http://github.com/symfony/symfony-standard.git .

# Remove unneeded vendor specific code
cat > app/autoload.php <<EOF
<?php

return require __DIR__.'/../vendor/autoload.php';
EOF

# Remove unneeded vendor bundles
cat > app/AppKernel.php <<EOF
<?php

use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;

class AppKernel extends Kernel
{
public function registerBundles()
{
return array(
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Acme\HelloBundle\AcmeHelloBundle(),
);
}

public function registerContainerConfiguration(LoaderInterface \$loader)
{
\$loader->load(__DIR__.'/config/config.yml');
}

public function getRootDir()
{
return __DIR__;
}
}
EOF

# Optimize the configuration
cat > app/config/config.yml <<EOF
framework:
router: { resource: "%kernel.root_dir%/config/routing.yml" }
templating: { engines: ['php'] }
secret: foobar
translator: { enabled: false }
EOF

# Add a route for the hello controller
cat > app/config/routing.yml <<EOF
_hello:
pattern: /hello/world
defaults: { _controller: AcmeHelloBundle:Hello:index }
EOF

# Create the Hello bundle directory structure
mkdir -p src/Acme/HelloBundle/Controller
mkdir -p src/Acme/HelloBundle/Resources/views

# Create the bundle class
cat > src/Acme/HelloBundle/AcmeHelloBundle.php <<EOF
<?php

namespace Acme\HelloBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class AcmeHelloBundle extends Bundle
{
}
EOF

# Create the controller
cat > src/Acme/HelloBundle/Controller/HelloController.php <<EOF
<?php

namespace Acme\HelloBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class HelloController extends Controller
{
public function indexAction()
{
return \$this->render('AcmeHelloBundle::index.html.php');
}
}
EOF

# Create the template
cat > src/Acme/HelloBundle/Resources/views/index.html.php <<EOF
Hello world
EOF

# Optimize the Request
sed s/Request/ApacheRequest/ web/app.php > tmp
mv tmp web/app.php

# Remove unneeded vendors from dependencies
cat > composer.json <<EOF
{
"name": "symfony/framework-hello-world-edition",
"description": "The \"Symfony Hello World Edition\" distribution (to be used for benchmarks)",
"autoload": {
"psr-0": { "": "src/" }
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "@stable",
"sensio/distribution-bundle": "@stable"
},
"replace": {
"doctrine/common": "*",
"twig/twig": "*"
},
"scripts": {
"post-install-cmd": [
"Sensio\\\Bundle\\\DistributionBundle\\\Composer\\\ScriptHandler::buildBootstrap",
"Sensio\\\Bundle\\\DistributionBundle\\\Composer\\\ScriptHandler::clearCache",
"Sensio\\\Bundle\\\DistributionBundle\\\Composer\\\ScriptHandler::installAssets",
"Sensio\\\Bundle\\\DistributionBundle\\\Composer\\\ScriptHandler::installRequirementsFile"
],
"post-update-cmd": [
"Sensio\\\Bundle\\\DistributionBundle\\\Composer\\\ScriptHandler::buildBootstrap",
"Sensio\\\Bundle\\\DistributionBundle\\\Composer\\\ScriptHandler::clearCache",
"Sensio\\\Bundle\\\DistributionBundle\\\Composer\\\ScriptHandler::installAssets",
"Sensio\\\Bundle\\\DistributionBundle\\\Composer\\\ScriptHandler::installRequirementsFile"
]
},
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web"
}
}
EOF

cat > composer.lock <<EOF
EOF

curl -s https://getcomposer.org/installer | php

# Install the dependencies:
php composer.phar install

# Benchmark!
Something went wrong with that request. Please try again.