Browse Source

initialize project

Laszlo Lang 3 months ago
commit
f32ba29e50

+ 10
- 0
.env.dist View File

@@ -0,0 +1,10 @@
1
+# This file is a "template" of which env vars need to be defined for your application
2
+# Copy this file to .env file for development, create environment variables when deploying to production
3
+# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
4
+
5
+###> symfony/framework-bundle ###
6
+APP_ENV=dev
7
+APP_SECRET=c78ebf740b9db52319c2c0a201923d62
8
+#TRUSTED_PROXIES=127.0.0.1,127.0.0.2
9
+#TRUSTED_HOSTS=localhost,example.com
10
+###< symfony/framework-bundle ###

+ 7
- 0
.gitignore View File

@@ -0,0 +1,7 @@
1
+
2
+###> symfony/framework-bundle ###
3
+/.env
4
+/public/bundles/
5
+/var/
6
+/vendor/
7
+###< symfony/framework-bundle ###

+ 39
- 0
bin/console View File

@@ -0,0 +1,39 @@
1
+#!/usr/bin/env php
2
+<?php
3
+
4
+use App\Kernel;
5
+use Symfony\Bundle\FrameworkBundle\Console\Application;
6
+use Symfony\Component\Console\Input\ArgvInput;
7
+use Symfony\Component\Debug\Debug;
8
+use Symfony\Component\Dotenv\Dotenv;
9
+
10
+set_time_limit(0);
11
+
12
+require __DIR__.'/../vendor/autoload.php';
13
+
14
+if (!class_exists(Application::class)) {
15
+    throw new \RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
16
+}
17
+
18
+if (!isset($_SERVER['APP_ENV'])) {
19
+    if (!class_exists(Dotenv::class)) {
20
+        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.');
21
+    }
22
+    (new Dotenv())->load(__DIR__.'/../.env');
23
+}
24
+
25
+$input = new ArgvInput();
26
+$env = $input->getParameterOption(['--env', '-e'], $_SERVER['APP_ENV'] ?? 'dev', true);
27
+$debug = (bool) ($_SERVER['APP_DEBUG'] ?? ('prod' !== $env)) && !$input->hasParameterOption('--no-debug', true);
28
+
29
+if ($debug) {
30
+    umask(0000);
31
+
32
+    if (class_exists(Debug::class)) {
33
+        Debug::enable();
34
+    }
35
+}
36
+
37
+$kernel = new Kernel($env, $debug);
38
+$application = new Application($kernel);
39
+$application->run($input);

+ 60
- 0
composer.json View File

@@ -0,0 +1,60 @@
1
+{
2
+    "type": "project",
3
+    "license": "proprietary",
4
+    "require": {
5
+        "php": "^7.1.3",
6
+        "ext-ctype": "*",
7
+        "ext-iconv": "*",
8
+        "symfony/console": "^4.1",
9
+        "symfony/flex": "^1.0",
10
+        "symfony/framework-bundle": "^4.1",
11
+        "symfony/lts": "^4@dev",
12
+        "symfony/yaml": "^4.1"
13
+    },
14
+    "require-dev": {
15
+        "symfony/dotenv": "^4.1"
16
+    },
17
+    "config": {
18
+        "preferred-install": {
19
+            "*": "dist"
20
+        },
21
+        "sort-packages": true
22
+    },
23
+    "autoload": {
24
+        "psr-4": {
25
+            "App\\": "src/"
26
+        }
27
+    },
28
+    "autoload-dev": {
29
+        "psr-4": {
30
+            "App\\Tests\\": "tests/"
31
+        }
32
+    },
33
+    "replace": {
34
+        "symfony/polyfill-ctype": "*",
35
+        "symfony/polyfill-iconv": "*",
36
+        "symfony/polyfill-php71": "*",
37
+        "symfony/polyfill-php70": "*",
38
+        "symfony/polyfill-php56": "*"
39
+    },
40
+    "scripts": {
41
+        "auto-scripts": {
42
+            "cache:clear": "symfony-cmd",
43
+            "assets:install %PUBLIC_DIR%": "symfony-cmd"
44
+        },
45
+        "post-install-cmd": [
46
+            "@auto-scripts"
47
+        ],
48
+        "post-update-cmd": [
49
+            "@auto-scripts"
50
+        ]
51
+    },
52
+    "conflict": {
53
+        "symfony/symfony": "*"
54
+    },
55
+    "extra": {
56
+        "symfony": {
57
+            "allow-contrib": false
58
+        }
59
+    }
60
+}

+ 1353
- 0
composer.lock
File diff suppressed because it is too large
View File


+ 5
- 0
config/bundles.php View File

@@ -0,0 +1,5 @@
1
+<?php
2
+
3
+return [
4
+    Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
5
+];

+ 3
- 0
config/packages/dev/routing.yaml View File

@@ -0,0 +1,3 @@
1
+framework:
2
+    router:
3
+        strict_requirements: true

+ 30
- 0
config/packages/framework.yaml View File

@@ -0,0 +1,30 @@
1
+framework:
2
+    secret: '%env(APP_SECRET)%'
3
+    #default_locale: en
4
+    #csrf_protection: true
5
+    #http_method_override: true
6
+
7
+    # Enables session support. Note that the session will ONLY be started if you read or write from it.
8
+    # Remove or comment this section to explicitly disable session support.
9
+    session:
10
+        handler_id: ~
11
+
12
+    #esi: true
13
+    #fragments: true
14
+    php_errors:
15
+        log: true
16
+
17
+    cache:
18
+        # Put the unique name of your app here: the prefix seed
19
+        # is used to compute stable namespaces for cache keys.
20
+        #prefix_seed: your_vendor_name/app_name
21
+
22
+        # The app cache caches to the filesystem by default.
23
+        # Other options include:
24
+
25
+        # Redis
26
+        #app: cache.adapter.redis
27
+        #default_redis_provider: redis://localhost
28
+
29
+        # APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
30
+        #app: cache.adapter.apcu

+ 3
- 0
config/packages/routing.yaml View File

@@ -0,0 +1,3 @@
1
+framework:
2
+    router:
3
+        strict_requirements: ~

+ 4
- 0
config/packages/test/framework.yaml View File

@@ -0,0 +1,4 @@
1
+framework:
2
+    test: true
3
+    session:
4
+        storage_id: session.storage.mock_file

+ 3
- 0
config/routes.yaml View File

@@ -0,0 +1,3 @@
1
+#index:
2
+#    path: /
3
+#    controller: App\Controller\DefaultController::index

+ 30
- 0
config/services.yaml View File

@@ -0,0 +1,30 @@
1
+# This file is the entry point to configure your own services.
2
+# Files in the packages/ subdirectory configure your dependencies.
3
+
4
+# Put parameters here that don't need to change on each machine where the app is deployed
5
+# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
6
+parameters:
7
+
8
+services:
9
+    # default configuration for services in *this* file
10
+    _defaults:
11
+        autowire: true      # Automatically injects dependencies in your services.
12
+        autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
13
+        public: false       # Allows optimizing the container by removing unused services; this also means
14
+                            # fetching services directly from the container via $container->get() won't work.
15
+                            # The best practice is to be explicit about your dependencies anyway.
16
+
17
+    # makes classes in src/ available to be used as services
18
+    # this creates a service per class whose id is the fully-qualified class name
19
+    App\:
20
+        resource: '../src/*'
21
+        exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'
22
+
23
+    # controllers are imported separately to make sure services can be injected
24
+    # as action arguments even if you don't extend any base controller class
25
+    App\Controller\:
26
+        resource: '../src/Controller'
27
+        tags: ['controller.service_arguments']
28
+
29
+    # add more service definitions when explicit configuration is needed
30
+    # please note that last definitions always *replace* previous ones

+ 39
- 0
public/index.php View File

@@ -0,0 +1,39 @@
1
+<?php
2
+
3
+use App\Kernel;
4
+use Symfony\Component\Debug\Debug;
5
+use Symfony\Component\Dotenv\Dotenv;
6
+use Symfony\Component\HttpFoundation\Request;
7
+
8
+require __DIR__.'/../vendor/autoload.php';
9
+
10
+// The check is to ensure we don't use .env in production
11
+if (!isset($_SERVER['APP_ENV'])) {
12
+    if (!class_exists(Dotenv::class)) {
13
+        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.');
14
+    }
15
+    (new Dotenv())->load(__DIR__.'/../.env');
16
+}
17
+
18
+$env = $_SERVER['APP_ENV'] ?? 'dev';
19
+$debug = (bool) ($_SERVER['APP_DEBUG'] ?? ('prod' !== $env));
20
+
21
+if ($debug) {
22
+    umask(0000);
23
+
24
+    Debug::enable();
25
+}
26
+
27
+if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? false) {
28
+    Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
29
+}
30
+
31
+if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? false) {
32
+    Request::setTrustedHosts(explode(',', $trustedHosts));
33
+}
34
+
35
+$kernel = new Kernel($env, $debug);
36
+$request = Request::createFromGlobals();
37
+$response = $kernel->handle($request);
38
+$response->send();
39
+$kernel->terminate($request, $response);

+ 0
- 0
src/Controller/.gitignore View File


+ 61
- 0
src/Kernel.php View File

@@ -0,0 +1,61 @@
1
+<?php
2
+
3
+namespace App;
4
+
5
+use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
6
+use Symfony\Component\Config\Loader\LoaderInterface;
7
+use Symfony\Component\Config\Resource\FileResource;
8
+use Symfony\Component\DependencyInjection\ContainerBuilder;
9
+use Symfony\Component\HttpKernel\Kernel as BaseKernel;
10
+use Symfony\Component\Routing\RouteCollectionBuilder;
11
+
12
+class Kernel extends BaseKernel
13
+{
14
+    use MicroKernelTrait;
15
+
16
+    const CONFIG_EXTS = '.{php,xml,yaml,yml}';
17
+
18
+    public function getCacheDir()
19
+    {
20
+        return $this->getProjectDir().'/var/cache/'.$this->environment;
21
+    }
22
+
23
+    public function getLogDir()
24
+    {
25
+        return $this->getProjectDir().'/var/log';
26
+    }
27
+
28
+    public function registerBundles()
29
+    {
30
+        $contents = require $this->getProjectDir().'/config/bundles.php';
31
+        foreach ($contents as $class => $envs) {
32
+            if (isset($envs['all']) || isset($envs[$this->environment])) {
33
+                yield new $class();
34
+            }
35
+        }
36
+    }
37
+
38
+    protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader)
39
+    {
40
+        $container->addResource(new FileResource($this->getProjectDir().'/config/bundles.php'));
41
+        // Feel free to remove the "container.autowiring.strict_mode" parameter
42
+        // if you are using symfony/dependency-injection 4.0+ as it's the default behavior
43
+        $container->setParameter('container.autowiring.strict_mode', true);
44
+        $container->setParameter('container.dumper.inline_class_loader', true);
45
+        $confDir = $this->getProjectDir().'/config';
46
+
47
+        $loader->load($confDir.'/{packages}/*'.self::CONFIG_EXTS, 'glob');
48
+        $loader->load($confDir.'/{packages}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, 'glob');
49
+        $loader->load($confDir.'/{services}'.self::CONFIG_EXTS, 'glob');
50
+        $loader->load($confDir.'/{services}_'.$this->environment.self::CONFIG_EXTS, 'glob');
51
+    }
52
+
53
+    protected function configureRoutes(RouteCollectionBuilder $routes)
54
+    {
55
+        $confDir = $this->getProjectDir().'/config';
56
+
57
+        $routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS, '/', 'glob');
58
+        $routes->import($confDir.'/{routes}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, '/', 'glob');
59
+        $routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, '/', 'glob');
60
+    }
61
+}

+ 89
- 0
symfony.lock View File

@@ -0,0 +1,89 @@
1
+{
2
+    "psr/cache": {
3
+        "version": "1.0.1"
4
+    },
5
+    "psr/container": {
6
+        "version": "1.0.0"
7
+    },
8
+    "psr/log": {
9
+        "version": "1.0.2"
10
+    },
11
+    "psr/simple-cache": {
12
+        "version": "1.0.1"
13
+    },
14
+    "symfony/cache": {
15
+        "version": "v4.1.3"
16
+    },
17
+    "symfony/config": {
18
+        "version": "v4.1.3"
19
+    },
20
+    "symfony/console": {
21
+        "version": "3.3",
22
+        "recipe": {
23
+            "repo": "github.com/symfony/recipes",
24
+            "branch": "master",
25
+            "version": "3.3",
26
+            "ref": "e3868d2f4a5104f19f844fe551099a00c6562527"
27
+        }
28
+    },
29
+    "symfony/debug": {
30
+        "version": "v4.1.3"
31
+    },
32
+    "symfony/dependency-injection": {
33
+        "version": "v4.1.3"
34
+    },
35
+    "symfony/dotenv": {
36
+        "version": "v4.1.3"
37
+    },
38
+    "symfony/event-dispatcher": {
39
+        "version": "v4.1.3"
40
+    },
41
+    "symfony/filesystem": {
42
+        "version": "v4.1.3"
43
+    },
44
+    "symfony/finder": {
45
+        "version": "v4.1.3"
46
+    },
47
+    "symfony/flex": {
48
+        "version": "1.0",
49
+        "recipe": {
50
+            "repo": "github.com/symfony/recipes",
51
+            "branch": "master",
52
+            "version": "1.0",
53
+            "ref": "e921bdbfe20cdefa3b82f379d1cd36df1bc8d115"
54
+        }
55
+    },
56
+    "symfony/framework-bundle": {
57
+        "version": "3.3",
58
+        "recipe": {
59
+            "repo": "github.com/symfony/recipes",
60
+            "branch": "master",
61
+            "version": "3.3",
62
+            "ref": "87c585d24de9f43bca80ebcfd5cf5cb39445d95f"
63
+        }
64
+    },
65
+    "symfony/http-foundation": {
66
+        "version": "v4.1.3"
67
+    },
68
+    "symfony/http-kernel": {
69
+        "version": "v4.1.3"
70
+    },
71
+    "symfony/lts": {
72
+        "version": "4-dev"
73
+    },
74
+    "symfony/polyfill-mbstring": {
75
+        "version": "v1.9.0"
76
+    },
77
+    "symfony/routing": {
78
+        "version": "4.0",
79
+        "recipe": {
80
+            "repo": "github.com/symfony/recipes",
81
+            "branch": "master",
82
+            "version": "4.0",
83
+            "ref": "cda8b550123383d25827705d05a42acf6819fe4e"
84
+        }
85
+    },
86
+    "symfony/yaml": {
87
+        "version": "v4.1.3"
88
+    }
89
+}