netpromotion / symfony-up
Up your Symfony App!
v2.0.0
2018-08-10 10:30 UTC
Requires
- php: >=7.1
- symfony/config: ^4.1
- symfony/console: ^4.1
- symfony/dependency-injection: ^4.1
- symfony/framework-bundle: ^4.1
- symfony/http-kernel: ^4.1
- symfony/routing: ^4.1
- symfony/yaml: ^4.1
Requires (Dev)
- sensio/framework-extra-bundle: ^5.2
- symfony/browser-kit: ^4.1
- symfony/dotenv: *
- symfony/flex: ^1.0
- symfony/phpunit-bridge: ^4.1
Suggests
- symfony/dotenv: Registers environment variables from a .env file
- symfony/flex: Composer plugin for Symfony
- symfony/phpunit-bridge: Provides utilities for PHPUnit, especially user deprecation notices management
- symfony/stopwatch: Provides a way to profile code
- symfony/web-profiler-bundle: Provides detailed technical information about each request execution and displays it in both the web debug toolbar and the profiler
Conflicts
- symfony/dotenv: <4.1 || >=5
This package is not auto-updated.
Last update: 2024-11-20 13:02:49 UTC
README
Symfony Up!
Up your Symfony App!
Getting started
Run composer require netpromotion/symfony-up
and optionally ./vendor/bin/symfony-up
which creates following files:
.env.dist
# This file is a "template" of which env vars need to be defined for your application # Copy this file to .env file for development, create environment variables when deploying to production # https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration ###> symfony/framework-bundle ### APP_ENV='dev' APP_SECRET='ThisIsNotSoSecretChangeIt' #TRUSTED_PROXIES='127.0.0.1,127.0.0.2' #TRUSTED_HOSTS='localhost,example.com' ###< symfony/framework-bundle ###
config/packages/framework.yaml
framework: # secret is commonly used to add more entropy to security related operations secret: '%env(APP_SECRET)%' # session.save_path is the path where the session files are created session: save_path: '%kernel.project_dir%/var/session/%kernel.environment%' # http_method_override determines whether the _method request parameter is used as the intended HTTP method on POST requests http_method_override: true # php_errors.log determines whether application logger is used instead of the PHP logger for logging PHP errors php_errors: log: true
config/packages/test/framework.yaml
framework: # test determines whether the services are related to testing your application test: true
config/bundles.php
<?php use Symfony\Bundle\FrameworkBundle\FrameworkBundle; return [ FrameworkBundle::class => ['all' => true], // TODO add more bundles here ];
config/routes/annotations.yaml
#controllers: # resource: ../../src/Controller/ # type: annotation
config/services.yaml
services: # _defaults.autowire determines whether it automatically injects dependencies in your services # _defaults.autoconfigure determines whether it automatically registers your services as commands, event subscribers, etc. # _defaults.public determines whether it allows optimizing the container by removing unused services _defaults: autowire: true autoconfigure: true public: false App\: resource: '../src/*' exclude: '../src/{Entity,Migrations,Tests,Kernel.php}' App\Controller\: resource: '../src/Controller' tags: ['controller.service_arguments']
src/Kernel.php
<?php namespace App; use Netpromotion\SymfonyUp\UpKernelTrait; use Netpromotion\SymfonyUp\UpKernel; class Kernel extends UpKernel { use UpKernelTrait; public function getProjectDir() { return __DIR__ . '/..'; } }
tests/TestCase.php
<?php namespace App\Test; use Netpromotion\SymfonyUp\UpTestCase; class TestCase extends UpTestCase { // Your own asserts goes here }
tests/bootstrap.php
<?php use Netpromotion\SymfonyUp\SymfonyUp; /** @var Composer\Autoload\ClassLoader $loader */ $loader = require __DIR__ . '/../vendor/autoload.php'; SymfonyUp::loadEnvironmentIfNeeded(__DIR__ . '/../.env'); // remove this line if you are using parameters instead of dotenv return $loader;
public/index.php
<?php use App\Kernel; use Netpromotion\SymfonyUp\SymfonyUp; use Symfony\Component\HttpFoundation\Request; require_once __DIR__ . '/../vendor/autoload.php'; Request::enableHttpMethodParameterOverride(); // remove this line if kernel.http_method_override = false SymfonyUp::loadEnvironmentIfNeeded(__DIR__ . '/../.env'); // remove this line if you are using parameters instead of dotenv SymfonyUp::createFromKernelClass(Kernel::class) ->runWeb();
public/.htaccess
DirectoryIndex index.php
# Uncomment the following line if you experience problems related to symlinks
# Options FollowSymlinks
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{HTTP:Authorization} .
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^ %{ENV:BASE}/index.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
RedirectMatch 302 ^/$ /index.php/
</IfModule>
</IfModule>
bin/console
#!/usr/bin/env php <?php use App\Kernel; use Netpromotion\SymfonyUp\SymfonyUp; require_once __DIR__ . '/../vendor/autoload.php'; SymfonyUp::loadEnvironmentIfNeeded(__DIR__ . '/../.env'); // remove this line if you are using parameters instead of dotenv SymfonyUp::createFromKernelClass(Kernel::class) ->runConsole();
phpunit.xml
<phpunit bootstrap="./tests/bootstrap.php" colors="true"> <testsuites> <testsuite> <directory suffix="Test.php">./tests/</directory> </testsuite> </testsuites> <php> <ini name="error_reporting" value="-1" /> <env name="KERNEL_CLASS" value="App\Kernel" /> <env name="APP_ENV" value="test" /> <env name="APP_DEBUG" value="1" /> <env name="APP_SECRET" value="s$cretf0rt3st" /> <env name="SHELL_VERBOSITY" value="-1" /> <!-- define your env variables for the test env below --> </php> </phpunit>