Skip to content

Commit

Permalink
initial app setup
Browse files Browse the repository at this point in the history
  • Loading branch information
chr-hertel committed Aug 18, 2019
0 parents commit dfea0af
Show file tree
Hide file tree
Showing 48 changed files with 7,431 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .env
@@ -0,0 +1,28 @@
# In all environments, the following files are loaded if they exist,
# the later taking precedence over the former:
#
# * .env contains default values for the environment variables needed by the app
# * .env.local uncommitted file with local overrides
# * .env.$APP_ENV committed environment-specific defaults
# * .env.$APP_ENV.local uncommitted environment-specific overrides
#
# Real environment variables win over .env files.
#
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
#
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration

###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=b0795f5bab7f1f59344cd7c85675454a
#TRUSTED_PROXIES=127.0.0.1,127.0.0.2
#TRUSTED_HOSTS='^localhost|example\.com$'
###< symfony/framework-bundle ###

###> doctrine/doctrine-bundle ###
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
# Configure your db driver and server_version in config/packages/doctrine.yaml
DATABASE_URL=sqlite:///%kernel.project_dir%/var/data.db
###< doctrine/doctrine-bundle ###
4 changes: 4 additions & 0 deletions .env.test
@@ -0,0 +1,4 @@
# define your env variables for the test env here
KERNEL_CLASS='App\Kernel'
APP_SECRET='$ecretf0rt3st'
SYMFONY_DEPRECATIONS_HELPER=999999
24 changes: 24 additions & 0 deletions .gitignore
@@ -0,0 +1,24 @@

###> symfony/framework-bundle ###
/.env.local
/.env.local.php
/.env.*.local
/public/bundles/
/var/
/vendor/
###< symfony/framework-bundle ###

###> symfony/web-server-bundle ###
/.web-server-pid
###< symfony/web-server-bundle ###

###> symfony/phpunit-bridge ###
.phpunit
.phpunit.result.cache
/phpunit.xml
###< symfony/phpunit-bridge ###

###> friendsofphp/php-cs-fixer ###
/.php_cs
/.php_cs.cache
###< friendsofphp/php-cs-fixer ###
14 changes: 14 additions & 0 deletions .php_cs.dist
@@ -0,0 +1,14 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->exclude('var')
;

return PhpCsFixer\Config::create()
->setRules([
'@Symfony' => true,
'array_syntax' => ['syntax' => 'short'],
])
->setFinder($finder)
;
19 changes: 19 additions & 0 deletions LICENSE
@@ -0,0 +1,19 @@
Copyright (c) 2019 Christian Flothmann & Christopher Hertel

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
55 changes: 55 additions & 0 deletions README.md
@@ -0,0 +1,55 @@
# Symfony Forms in Detail

Repository contains example application used for "Symfony Forms in Detail" at [Web Summer Camp 2019](https://2019.websummercamp.com/)

## Requirements

* PHP >= 7.1.3
* [Doctrine compatible](https://www.doctrine-project.org/projects/doctrine-dbal/en/2.9/reference/introduction.html#introduction) database layer, eg. SQlite

## Setting up the application

**Checkout & Build**

```bash
$ git clone git@github.com:chr-hertel/product-crud.git
$ cd product-crud
$ composer install
```

**Database**

Configure your database connection using `DATABASE_URL` in `.env`

```bash
$ bin/console doctrine:database:create
$ bin/console doctrine:schema:create --force
```

**Webserver**

Configure your vhost root to point to `public/` or use

```bash
$ bin/console server:start
```

and open homepage (eg http://localhost:8000)

## Quality Checks

You can execute the configured quality checks by running

```bash
$ bin/check
```

It will execute:

* Symfony Yaml- and Twig-Linting
* Doctrine Schema Validation
* Composer Validation
* PHPStan Static Code Analysis
* PHP-CS-Fixer Code Style
* Security Checker
* PHPUnit Testing
23 changes: 23 additions & 0 deletions bin/check
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

# file linting
bin/console lint:yaml config
bin/console lint:twig templates --env=prod

# schema validation
bin/console doctrine:schema:validate --skip-sync

# composer validation
composer validate

# static code analysis
vendor/bin/phpstan analyse

# code style
vendor/bin/php-cs-fixer fix --dry-run

# security check
vendor/bin/security-checker security:check

# tests
bin/phpunit
42 changes: 42 additions & 0 deletions bin/console
@@ -0,0 +1,42 @@
#!/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 (false === in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
echo 'Warning: The console should be invoked via the CLI version of PHP, not the '.\PHP_SAPI.' SAPI'.\PHP_EOL;
}

set_time_limit(0);

require dirname(__DIR__).'/vendor/autoload.php';

if (!class_exists(Application::class)) {
throw new RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
}

$input = new ArgvInput();
if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) {
putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env);
}

if ($input->hasParameterOption('--no-debug', true)) {
putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
}

require dirname(__DIR__).'/config/bootstrap.php';

if ($_SERVER['APP_DEBUG']) {
umask(0000);

if (class_exists(Debug::class)) {
Debug::enable();
}
}

$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$application = new Application($kernel);
$application->run($input);
13 changes: 13 additions & 0 deletions bin/phpunit
@@ -0,0 +1,13 @@
#!/usr/bin/env php
<?php

if (!file_exists(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php')) {
echo "Unable to find the `simple-phpunit.php` script in `vendor/symfony/phpunit-bridge/bin/`.\n";
exit(1);
}

if (false === getenv('SYMFONY_PHPUNIT_DIR')) {
putenv('SYMFONY_PHPUNIT_DIR='.__DIR__.'/.phpunit');
}

require dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php';
86 changes: 86 additions & 0 deletions composer.json
@@ -0,0 +1,86 @@
{
"name": "chr-hertel/product-crud",
"type": "project",
"description": "Example application for extending Symfony Forms",
"license": "MIT",
"require": {
"php": "^7.1.3",
"ext-ctype": "*",
"ext-iconv": "*",
"ext-json": "*",
"doctrine/doctrine-bundle": "^1.6.10",
"doctrine/doctrine-migrations-bundle": "^1.3 || ^2.0",
"doctrine/orm": "^2.5.11",
"sensio/framework-extra-bundle": "^5.4",
"symfony/asset": "4.3.*",
"symfony/console": "4.3.*",
"symfony/dotenv": "4.3.*",
"symfony/flex": "^1.3.1",
"symfony/form": "4.3.*",
"symfony/framework-bundle": "4.3.*",
"symfony/monolog-bundle": "^3.4",
"symfony/twig-bundle": "4.3.*",
"symfony/validator": "4.3.*",
"symfony/yaml": "4.3.*"
},
"replace": {
"paragonie/random_compat": "2.*",
"symfony/polyfill-ctype": "*",
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php56": "*",
"symfony/polyfill-php70": "*",
"symfony/polyfill-php71": "*"
},
"conflict": {
"symfony/symfony": "*"
},
"require-dev": {
"easycorp/easy-log-handler": "^1.0.7",
"friendsofphp/php-cs-fixer": "^2.15",
"phpstan/phpstan": "^0.11.15",
"sensiolabs/security-checker": "^6.0",
"symfony/browser-kit": "*",
"symfony/css-selector": "*",
"symfony/debug-bundle": "*",
"symfony/phpunit-bridge": "*",
"symfony/stopwatch": "*",
"symfony/var-dumper": "*",
"symfony/web-profiler-bundle": "*",
"symfony/web-server-bundle": "4.3.*"
},
"config": {
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"extra": {
"symfony": {
"allow-contrib": false,
"require": "4.3.*"
}
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"scripts": {
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
],
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd",
"security-checker security:check": "script"
}
}
}

0 comments on commit dfea0af

Please sign in to comment.