瀏覽代碼

Default 4.2-BETA1 installation

symfony_4.2_rest-api
Steevan BARBOYON 7 年之前
當前提交
78af1b4949

+ 12
- 0
.env 查看文件

@@ -0,0 +1,12 @@
1
+# This file defines all environment variables that the application needs.
2
+# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE.
3
+# Use ".env.local" for local overrides during development.
4
+# Use real environment variables when deploying to production.
5
+# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
6
+
7
+###> symfony/framework-bundle ###
8
+APP_ENV=dev
9
+APP_SECRET=ad33d4d8b44231f5233cd8dfd8f355bc
10
+#TRUSTED_PROXIES=127.0.0.1,127.0.0.2
11
+#TRUSTED_HOSTS=localhost,example.com
12
+###< symfony/framework-bundle ###

+ 9
- 0
.gitignore 查看文件

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

+ 40
- 0
bin/console 查看文件

@@ -0,0 +1,40 @@
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
+
9
+set_time_limit(0);
10
+
11
+require dirname(__DIR__).'/vendor/autoload.php';
12
+
13
+if (!class_exists(Application::class)) {
14
+    throw new RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
15
+}
16
+
17
+$input = new ArgvInput();
18
+if (null !== $_ENV['APP_ENV'] = $input->getParameterOption(['--env', '-e'], null, true)) {
19
+    putenv('APP_ENV='.$_ENV['APP_ENV']);
20
+    // force loading .env files when --env is defined
21
+    $_SERVER['APP_ENV'] = null;
22
+}
23
+
24
+if ($input->hasParameterOption('--no-debug', true)) {
25
+    putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
26
+}
27
+
28
+require dirname(__DIR__).'/src/.bootstrap.php';
29
+
30
+if ($_SERVER['APP_DEBUG']) {
31
+    umask(0000);
32
+
33
+    if (class_exists(Debug::class)) {
34
+        Debug::enable();
35
+    }
36
+}
37
+
38
+$kernel = new Kernel($_SERVER['APP_ENV'], $_SERVER['APP_DEBUG']);
39
+$application = new Application($kernel);
40
+$application->run($input);

+ 62
- 0
composer.json 查看文件

@@ -0,0 +1,62 @@
1
+{
2
+    "type": "project",
3
+    "license": "proprietary",
4
+    "minimum-stability": "dev",
5
+    "require": {
6
+        "php": "^7.1.3",
7
+        "ext-ctype": "*",
8
+        "ext-iconv": "*",
9
+        "symfony/console": "4.2.*",
10
+        "symfony/flex": "^1.1",
11
+        "symfony/framework-bundle": "4.2.*",
12
+        "symfony/yaml": "4.2.*"
13
+    },
14
+    "require-dev": {
15
+        "symfony/dotenv": "4.2.*"
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
+        "paragonie/random_compat": "2.*",
35
+        "symfony/polyfill-ctype": "*",
36
+        "symfony/polyfill-iconv": "*",
37
+        "symfony/polyfill-php71": "*",
38
+        "symfony/polyfill-php70": "*",
39
+        "symfony/polyfill-php56": "*"
40
+    },
41
+    "scripts": {
42
+        "auto-scripts": {
43
+            "cache:clear": "symfony-cmd",
44
+            "assets:install %PUBLIC_DIR%": "symfony-cmd"
45
+        },
46
+        "post-install-cmd": [
47
+            "@auto-scripts"
48
+        ],
49
+        "post-update-cmd": [
50
+            "@auto-scripts"
51
+        ]
52
+    },
53
+    "conflict": {
54
+        "symfony/symfony": "*"
55
+    },
56
+    "extra": {
57
+        "symfony": {
58
+            "allow-contrib": false,
59
+            "require": "4.2.*"
60
+        }
61
+    }
62
+}

+ 1403
- 0
composer.lock
文件差異過大導致無法顯示
查看文件


+ 5
- 0
config/bundles.php 查看文件

@@ -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 查看文件

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

+ 32
- 0
config/packages/framework.yaml 查看文件

@@ -0,0 +1,32 @@
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
+        cookie_secure: auto
12
+        cookie_samesite: lax
13
+
14
+    #esi: true
15
+    #fragments: true
16
+    php_errors:
17
+        log: true
18
+
19
+    cache:
20
+        # Put the unique name of your app here: the prefix seed
21
+        # is used to compute stable namespaces for cache keys.
22
+        #prefix_seed: your_vendor_name/app_name
23
+
24
+        # The app cache caches to the filesystem by default.
25
+        # Other options include:
26
+
27
+        # Redis
28
+        #app: cache.adapter.redis
29
+        #default_redis_provider: redis://localhost
30
+
31
+        # APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
32
+        #app: cache.adapter.apcu

+ 4
- 0
config/packages/routing.yaml 查看文件

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

+ 4
- 0
config/packages/test/framework.yaml 查看文件

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

+ 3
- 0
config/packages/test/routing.yaml 查看文件

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

+ 3
- 0
config/routes.yaml 查看文件

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

+ 27
- 0
config/services.yaml 查看文件

@@ -0,0 +1,27 @@
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
+
14
+    # makes classes in src/ available to be used as services
15
+    # this creates a service per class whose id is the fully-qualified class name
16
+    App\:
17
+        resource: '../src/*'
18
+        exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'
19
+
20
+    # controllers are imported separately to make sure services can be injected
21
+    # as action arguments even if you don't extend any base controller class
22
+    App\Controller\:
23
+        resource: '../src/Controller'
24
+        tags: ['controller.service_arguments']
25
+
26
+    # add more service definitions when explicit configuration is needed
27
+    # please note that last definitions always *replace* previous ones

+ 27
- 0
public/index.php 查看文件

@@ -0,0 +1,27 @@
1
+<?php
2
+
3
+use App\Kernel;
4
+use Symfony\Component\Debug\Debug;
5
+use Symfony\Component\HttpFoundation\Request;
6
+
7
+require dirname(__DIR__).'/src/.bootstrap.php';
8
+
9
+if ($_SERVER['APP_DEBUG']) {
10
+    umask(0000);
11
+
12
+    Debug::enable();
13
+}
14
+
15
+if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) {
16
+    Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
17
+}
18
+
19
+if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false) {
20
+    Request::setTrustedHosts(explode(',', $trustedHosts));
21
+}
22
+
23
+$kernel = new Kernel($_SERVER['APP_ENV'], $_SERVER['APP_DEBUG']);
24
+$request = Request::createFromGlobals();
25
+$response = $kernel->handle($request);
26
+$response->send();
27
+$kernel->terminate($request, $response);

+ 21
- 0
src/.bootstrap.php 查看文件

@@ -0,0 +1,21 @@
1
+<?php
2
+
3
+use Symfony\Component\Dotenv\Dotenv;
4
+
5
+require dirname(__DIR__).'/vendor/autoload.php';
6
+
7
+if (!array_key_exists('APP_ENV', $_SERVER)) {
8
+    $_SERVER['APP_ENV'] = $_ENV['APP_ENV'] ?? null;
9
+}
10
+
11
+if ('prod' !== $_SERVER['APP_ENV']) {
12
+    if (!class_exists(Dotenv::class)) {
13
+        throw new RuntimeException('The "APP_ENV" environment variable is not set to "prod". Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
14
+    }
15
+
16
+    (new Dotenv())->loadEnv(dirname(__DIR__).'/.env');
17
+}
18
+
19
+$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $_SERVER['APP_ENV'] ?: $_ENV['APP_ENV'] ?: 'dev';
20
+$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV'];
21
+$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0';

+ 0
- 0
src/Controller/.gitignore 查看文件


+ 58
- 0
src/Kernel.php 查看文件

@@ -0,0 +1,58 @@
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 ($envs[$this->environment] ?? $envs['all'] ?? false) {
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
+        $container->setParameter('container.dumper.inline_class_loader', true);
42
+        $confDir = $this->getProjectDir().'/config';
43
+
44
+        $loader->load($confDir.'/{packages}/*'.self::CONFIG_EXTS, 'glob');
45
+        $loader->load($confDir.'/{packages}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, 'glob');
46
+        $loader->load($confDir.'/{services}'.self::CONFIG_EXTS, 'glob');
47
+        $loader->load($confDir.'/{services}_'.$this->environment.self::CONFIG_EXTS, 'glob');
48
+    }
49
+
50
+    protected function configureRoutes(RouteCollectionBuilder $routes)
51
+    {
52
+        $confDir = $this->getProjectDir().'/config';
53
+
54
+        $routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS, '/', 'glob');
55
+        $routes->import($confDir.'/{routes}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, '/', 'glob');
56
+        $routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, '/', 'glob');
57
+    }
58
+}

+ 92
- 0
symfony.lock 查看文件

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

Loading…
取消
儲存