├── .gitignore ├── LICENSE ├── README.md ├── app ├── AppKernel.php ├── Resources │ └── AcmeHelloBundle │ │ └── views │ │ └── Default │ │ └── hello.html.twig ├── config │ ├── config.yml │ ├── routing_dev.yml │ └── routing_prod.yml └── console ├── composer.json ├── src └── Acme │ └── HelloBundle │ ├── AcmeHelloBundle.php │ └── Controller │ └── DefaultController.php └── web ├── .htaccess └── index.php /.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | vendor 3 | composer.lock 4 | app/cache 5 | app/logs 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2004-2014 Fabien Potencier 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Symfony Minimal Distribution 2 | 3 | This is the minimal Symfony distribution. 4 | 5 | It only contains the following bundles: 6 | 7 | - FrameworkBundle 8 | - MonologBundle 9 | - TwigBundle 10 | - WebDebugBundle in `dev`-environment 11 | 12 | It only contains one configuration file at `app/config/config.yml` 13 | that is parameterized by a environment variables from the 14 | phpdotenv file `.env` that you need to create in the project root. 15 | 16 | This file contains environment variables: 17 | 18 | SYMFONY_ENV=dev 19 | SYMFONY_DEBUG=1 20 | SYMFONY__SECRET=abcdefg 21 | SYMFONY__MONOLOG_ACTION_LEVEL=debug 22 | 23 | Blog post explaining the reasoning for this approach: 24 | 25 | - http://whitewashing.de/2014/10/26/symfony_all_the_things_web.html 26 | 27 | ### PHP built-in web server using `app/console server:[run|start]` 28 | 29 | You need to modify the `web/index.php` file by adding `Dotenv::makeMutable();` 30 | before the call to `Dotenv::load()`: 31 | 32 | ```php 33 | handle($request); 46 | $response->send(); 47 | $kernel->terminate($request, $response); 48 | ``` 49 | -------------------------------------------------------------------------------- /app/AppKernel.php: -------------------------------------------------------------------------------- 1 | getEnvironment(), array('dev', 'test'))) { 18 | $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(); 19 | } 20 | 21 | return $bundles; 22 | } 23 | 24 | public function registerContainerConfiguration(LoaderInterface $loader) 25 | { 26 | $loader->load(__DIR__ . '/config/config.yml'); 27 | 28 | if (in_array($this->getEnvironment(), array('dev', 'test'))) { 29 | $loader->load(function ($container) { 30 | $container->loadFromExtension('web_profiler', array( 31 | 'toolbar' => true, 32 | )); 33 | }); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/Resources/AcmeHelloBundle/views/Default/hello.html.twig: -------------------------------------------------------------------------------- 1 | 2 |
3 | Hello {{ name }}! 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/config/config.yml: -------------------------------------------------------------------------------- 1 | # app/config/config.yml 2 | framework: 3 | secret: %secret% 4 | router: 5 | resource: "%kernel.root_dir%/config/routing_%kernel.environment%.yml" 6 | strict_requirements: %kernel.debug% 7 | templating: 8 | engines: ['twig'] 9 | profiler: 10 | enabled: %kernel.debug% 11 | 12 | monolog: 13 | handlers: 14 | main: 15 | type: fingers_crossed 16 | action_level: %monolog_action_level% 17 | handler: nested 18 | nested: 19 | type: stream 20 | path: "%kernel.logs_dir%/%kernel.environment%.log" 21 | level: debug 22 | -------------------------------------------------------------------------------- /app/config/routing_dev.yml: -------------------------------------------------------------------------------- 1 | _wdt: 2 | resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml" 3 | prefix: /_wdt 4 | 5 | _profiler: 6 | resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml" 7 | prefix: /_profiler 8 | 9 | _main: 10 | resource: routing_prod.yml 11 | -------------------------------------------------------------------------------- /app/config/routing_prod.yml: -------------------------------------------------------------------------------- 1 | hello_world: 2 | pattern: /hello/{name} 3 | defaults: 4 | _controller: "AcmeHelloBundle:Default:hello" 5 | -------------------------------------------------------------------------------- /app/console: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | load(); 16 | 17 | $input = new ArgvInput(); 18 | $kernel = new AppKernel($_SERVER['SYMFONY_ENV'], (bool)$_SERVER['SYMFONY_DEBUG']); 19 | $application = new Application($kernel); 20 | $application->run($input); 21 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": { 3 | "symfony/symfony": "@stable", 4 | "symfony/monolog-bundle": "@stable", 5 | "vlucas/phpdotenv": "~2.0" 6 | }, 7 | "autoload": { 8 | "psr-0": { "Acme": "src/" } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/Acme/HelloBundle/AcmeHelloBundle.php: -------------------------------------------------------------------------------- 1 | render( 12 | 'AcmeHelloBundle:Default:hello.html.twig', 13 | array('name' => $name) 14 | ); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /web/.htaccess: -------------------------------------------------------------------------------- 1 |