Commit 481aaca5 authored by Emma's avatar Emma 😻

upgrade to symfony flex

parent ade5d5f9
# 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
SITE_NAME=Postmill
NO_REPLY_ADDRESS="no-reply@example.com"
###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET="change this in prod or die"
#TRUSTED_PROXIES=127.0.0.1,127.0.0.2
#TRUSTED_HOSTS=localhost,example.com
###< symfony/framework-bundle ###
###> doctrine/doctrine-bundle ###
# Change the username, password, host, database name and server version
# according to your setup. Don't even think about trying another kind of
# database, it won't work
DATABASE_URL=pgsql://db_user:db_password@localhost:3306/db_name?serverVersion=9.6
###< doctrine/doctrine-bundle ###
###> symfony/swiftmailer-bundle ###
# For Gmail as a transport, use: "gmail://username:password@localhost"
# For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode="
# Delivery is disabled by default via "null://localhost"
MAILER_URL=null://localhost
###< symfony/swiftmailer-bundle ###
.idea/
*.phar
*.iml
.DS_Store
*.phar
*.sw[a-z]
*~
tags
.web-server-pid
/app/config/parameters.yml
/build/
/node_modules/
/phpunit.xml
/var/*
!/var/cache
/var/cache/*
!var/cache/.gitkeep
!/var/logs
/var/logs/*
!var/logs/.gitkeep
!/var/sessions
/var/sessions/*
!var/sessions/.gitkeep
!var/SymfonyRequirements.php
/vendor/
/web/build/
/web/bundles/
/web/media/
/web/submission_images/
/public/build/
/public/media/
/public/submission_images/
## legacy
/web/css/
/web/js/
/web/fonts/
/app/
/web/
###> symfony/framework-bundle ###
.env
/public/bundles/
/var/
/vendor/
###< symfony/framework-bundle ###
###> friendsofphp/php-cs-fixer ###
.php_cs
.php_cs.cache
###< friendsofphp/php-cs-fixer ###
###> symfony/phpunit-bridge ###
.phpunit
/phpunit.xml
###< symfony/phpunit-bridge ###
###> symfony/web-server-bundle ###
.web-server-pid
###< symfony/web-server-bundle ###
......@@ -25,4 +25,4 @@ variables:
test:
script:
- vendor/bin/simple-phpunit --coverage-text --colors=never
- bin/phpunit --coverage-text --colors=never
......@@ -24,32 +24,30 @@ Clone the repository somewhere and navigate there with the command line.
1. Run `npm install`.
2. Run `npm run build-dev`. The `web/build/` directory should now contain some
files.
2. Run `npm run build-dev`. The `public/build/` directory should now contain
some files.
### Setting up the backend
1. Run `composer install`. You should be prompted for database credentials,
mail sending stuff, and a secret token. You can leave the default values for
the mail stuff, but you must supply valid database credentials.
1. Run `composer install`.
2. You should now have a `.env` file in the project root. Edit this to your
liking or leave the defaults alone, but you *must* change `DATABASE_URL`.
Instructions for setting up a database can be found at
[docs/database-setup.md](docs/database-setup.md).
If this step fails, you can remove or edit `app/config/parameters.yml` and
run `composer install` to try again.
2. Run `bin/symfony_requirements` to check that your environment meets the
requirements needed to run the software. Fix any errors that arise.
3. Run `vendor/bin/requirements-checker` to ensure your environment meets
necessary requirements needed to run Postmill. Fix any errors that arise.
3. Run `bin/console doctrine:migrations:migrate` to load the database schema.
4. Run `bin/console doctrine:migrations:migrate` to load the database schema.
4. Run `bin/console app:user:add <username> --admin` to create a user account.
5. Run `bin/console app:user:add <username> --admin` to create a user account.
5. Run `bin/console server:run` to start the application.
6. Run `bin/console server:run` to start the application.
6. Navigate to <http://localhost:8000/>. Log in with the credentials you chose
in step 4.
7. Navigate to <http://localhost:8000/>. Log in with the credentials you chose
in step 2.
## Reporting issues
......
<?php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel {
public function registerBundles() {
$bundles = [
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
new Bazinga\Bundle\JsTranslationBundle\BazingaJsTranslationBundle(),
new Liip\ImagineBundle\LiipImagineBundle(),
new FOS\JsRoutingBundle\FOSJsRoutingBundle(),
new WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(),
new Gregwar\CaptchaBundle\GregwarCaptchaBundle(),
new Oneup\FlysystemBundle\OneupFlysystemBundle(),
new AppBundle\AppBundle(),
];
if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle();
if ($this->getEnvironment() === 'test') {
$bundles[] = new DAMA\DoctrineTestBundle\DAMADoctrineTestBundle();
}
}
return $bundles;
}
public function getRootDir() {
return __DIR__;
}
public function getCacheDir() {
return dirname(__DIR__).'/var/cache/'.$this->getEnvironment();
}
public function getLogDir() {
return dirname(__DIR__).'/var/logs';
}
public function registerContainerConfiguration(LoaderInterface $loader) {
$loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
}
}
// hack: see workarounds.md
class_alias('AppBundle\Entity\User', 'Raddit\AppBundle\Entity\User');
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
# Put parameters here that don't need to change on each machine where the app is deployed
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
days_to_keep_logs: 7
user_forum_creation_interval: 1 day
uuid_regex: '[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}'
wiki_page_regex: '[A-Za-z][A-Za-z0-9_-]*(/[A-Za-z][A-Za-z0-9_-]*)*'
locale: en
framework:
#esi: ~
translator:
fallbacks: ["%locale%"]
paths:
- "%kernel.project_dir%/translations/"
secret: "%env(SECRET)%"
router:
resource: "%kernel.project_dir%/app/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
serializer: { enable_annotations: true }
templating:
engines: ['twig']
default_locale: "%locale%"
trusted_hosts: ~
session:
# http://symfony.com/doc/current/reference/configuration/framework.html#handler-id
handler_id: session.handler.native_file
save_path: "%kernel.project_dir%/var/sessions/%kernel.environment%"
fragments: ~
http_method_override: false
assets:
json_manifest_path: "%kernel.project_dir%/web/build/manifest.json"
php_errors:
log: true
cache: { app: cache.system }
web_link: { enabled: true }
# Twig Configuration
twig:
paths:
- "%kernel.project_dir%/templates"
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
form_themes:
- "_forms/standard_form_theme.html.twig"
# Doctrine Configuration
doctrine:
dbal:
driver: pdo_pgsql
url: "%env(DATABASE_URL)%"
charset: UTF8
types:
inet: AppBundle\DBAL\Type\InetType
uuid: Ramsey\Uuid\Doctrine\UuidType
mapping_types:
inet: inet
uuid: uuid
orm:
auto_generate_proxy_classes: "%kernel.debug%"
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: "%env(MAILER_TRANSPORT)%"
host: "%env(MAILER_HOST)%"
username: "%env(MAILER_USER)%"
password: "%env(MAILER_PASSWORD)%"
spool: { type: memory }
doctrine_migrations:
dir_name: "%kernel.project_dir%/src/AppBundle/Migrations"
namespace: DoctrineMigrations
name: Postmill migrations
# todo: use flysystem for thumbnails too
liip_imagine:
loaders:
submission_images:
flysystem:
filesystem_service: oneup_flysystem.submission_images_filesystem
filter_sets:
submission_thumbnail:
data_loader: submission_images
filters:
thumbnail:
size: [200, 200]
mode: outbound
quality: 70
oneup_flysystem:
adapters:
submission_images:
local:
directory: "%kernel.project_dir%/web/submission_images"
filesystems:
submission_images: { adapter: submission_images }
imports:
- { resource: config.yml }
doctrine:
orm:
metadata_cache_driver: apcu
#result_cache_driver: apcu
query_cache_driver: apcu
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
nested:
type: rotating_file
max_files: "%days_to_keep_logs%"
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
console:
type: console
imports:
- { resource: config_dev.yml }
framework:
test: ~
session:
storage_id: session.storage.mock_file
profiler:
enabled: true
collect: false
assets:
json_manifest_path: ~
web_profiler:
toolbar: false
intercept_redirects: false
swiftmailer:
disable_delivery: true
# This file is a "template" of what your parameters.yml file should look like
# Set parameters here that may be different on each deployment target of the app, e.g. development, staging, production.
# http://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
parameters:
env(DATABASE_URL): "pgsql://user:password@host/dbname?serverVersion=9.3"
env(MAILER_TRANSPORT): smtp
env(MAILER_HOST): 127.0.0.1
env(MAILER_USER): ~
env(MAILER_PASSWORD): ~
env(SITE_NAME): Postmill
# The email address automated messages will be sent from
env(NO_REPLY_ADDRESS): no-reply@example.com
# A secret key that's used to generate certain security-related tokens
env(SECRET): ThisTokenIsNotSoSecretChangeIt
_ajax:
resource: routes/ajax.yml
_ban:
resource: routes/ban.yml
_comment:
resource: routes/comment.yml
_forum:
resource: routes/forum.yml
_front:
resource: routes/front.yml
_message:
resource: routes/message.yml
_reset_password:
resource: routes/reset_password.yml
_security:
resource: routes/security.yml
_submission:
resource: routes/submission.yml
_theme:
resource: routes/theme.yml
_user:
resource: routes/user.yml
_wiki:
resource: routes/wiki.yml
_bazinga_jstranslation:
resource: "@BazingaJsTranslationBundle/Resources/config/routing/routing.yml"
prefix: /_t/
_liip_imagine:
resource: "@LiipImagineBundle/Resources/config/routing.yaml"
_gregwar_captcha_routing:
resource: "@GregwarCaptchaBundle/Resources/config/routing/routing.yml"
prefix: /_gcb
_fos_js_routing:
resource: "@FOSJsRoutingBundle/Resources/config/routing/routing.xml"
_trailing_slash_redirect:
controller: AppBundle\Controller\RedirectingController::removeTrailingSlash
path: /{url}
requirements: { url: '.*/$' }
_wdt:
resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
prefix: /_wdt
_profiler:
resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
prefix: /_profiler
_errors:
resource: "@TwigBundle/Resources/config/routing/errors.xml"
prefix: /_error
_main:
resource: routing.yml
#!/usr/bin/env php
<?php
use App\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Debug\Debug;
// if you don't want to setup permissions the proper way, just uncomment the following PHP line
// read http://symfony.com/doc/current/setup.html#checking-symfony-application-configuration-and-setup
// for more information
//umask(0000);
use Symfony\Component\Dotenv\Dotenv;
set_time_limit(0);
require __DIR__.'/../vendor/autoload.php';
if (!class_exists(Application::class)) {
throw new \RuntimeException(
'You need to add "symfony/framework-bundle" as a Composer dependency.'
);
}
if (!isset($_SERVER['APP_ENV'])) {
if (!class_exists(Dotenv::class)) {
throw new \RuntimeException(
'APP_ENV environment variable is not defined. You need to define '.
'environment variables for configuration or add "symfony/dotenv" '.
'as a Composer dependency to load variables from a .env file.'
);
}
(new Dotenv())->load(__DIR__.'/../.env');
}
$input = new ArgvInput();
$env = $input->getParameterOption(['--env', '-e'], getenv('SYMFONY_ENV') ?: 'dev');
$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(['--no-debug', '']) && $env !== 'prod';
$env = $input->getParameterOption(['--env', '-e'], $_SERVER['APP_ENV'] ?? 'dev');
$debug = ($_SERVER['APP_DEBUG'] ?? ('prod' !== $env)) && !$input->hasParameterOption(['--no-debug', '']);
if ($debug) {
Debug::enable();
umask(0000);
if (class_exists(Debug::class)) {
Debug::enable();
}
}
$kernel = new AppKernel($env, $debug);
$kernel = new Kernel($env, $debug);
$application = new Application($kernel);
$application->run($input);
#!/usr/bin/env php
<?php
if (!file_exists(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) {
echo "Unable to find the `simple-phpunit` script in `vendor/symfony/phpunit-bridge/bin/`.\n";
exit(1);
}
if (false === getenv('SYMFONY_PHPUNIT_REMOVE')) {
putenv('SYMFONY_PHPUNIT_REMOVE=symfony/yaml');
}
if (false === getenv('SYMFONY_PHPUNIT_VERSION')) {
putenv('SYMFONY_PHPUNIT_VERSION=6.5');
}
if (false === getenv('SYMFONY_PHPUNIT_DIR')) {
putenv('SYMFONY_PHPUNIT_DIR='.__DIR__.'/.phpunit');
}
require dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit';
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Symfony\Requirements\Requirement;
use Symfony\Requirements\SymfonyRequirements;
if (file_exists($autoloader = __DIR__.'/../../../autoload.php')) {
require_once $autoloader;
} elseif (file_exists($autoloader = __DIR__.'/../vendor/autoload.php')) {
require_once $autoloader;
} else {
throw new \RuntimeException('Unable to find the Composer autoloader.');
}
$lineSize = 70;
$symfonyRequirements = new SymfonyRequirements(dirname(dirname(realpath($autoloader))));
$iniPath = $symfonyRequirements->getPhpIniPath();
echo_title('Symfony Requirements Checker');
echo '> PHP is using the following php.ini file:'.PHP_EOL;
if ($iniPath) {
echo_style('green', ' '.$iniPath);
} else {
echo_style('yellow', ' WARNING: No configuration file (php.ini) used by PHP!');
}
echo PHP_EOL.PHP_EOL;
echo '> Checking Symfony requirements:'.PHP_EOL.' ';
$messages = array();
foreach ($symfonyRequirements->getRequirements() as $req) {
if ($helpText = get_error_message($req, $lineSize)) {
echo_style('red', 'E');
$messages['error'][] = $helpText;
} else {
echo_style('green', '.');
}
}
$checkPassed = empty($messages['error']);
foreach ($symfonyRequirements->getRecommendations() as $req) {
if ($helpText = get_error_message($req, $lineSize)) {
echo_style('yellow', 'W');
$messages['warning'][] = $helpText;
} else {
echo_style('green', '.');
}
}
if ($checkPassed) {
echo_block('success', 'OK', 'Your system is ready to run Symfony projects');
} else {
echo_block('error', 'ERROR', 'Your system is not ready to run Symfony projects');
echo_title('Fix the following mandatory requirements', 'red');
foreach ($messages['error'] as $helpText) {
echo ' * '.$helpText.PHP_EOL;
}
}
if (!empty($messages['warning'])) {
echo_title('Optional recommendations to improve your setup', 'yellow');
foreach ($messages['warning'] as $helpText) {
echo ' * '.$helpText.PHP_EOL;
}
}
echo PHP_EOL;