Selaa lähdekoodia

Symfony 4.0, HelloWorld and Rest benchmarks installation

tags/4.0.15.1
Steevan BARBOYON 8 vuotta sitten
commit
2e98a78d41

+ 8
- 0
.env.dist Näytä tiedosto

@@ -0,0 +1,8 @@
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=2d89aad842f1f606283c4246512d616b
8
+###< symfony/framework-bundle ###

+ 8
- 0
.gitignore Näytä tiedosto

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

+ 40
- 0
bin/console Näytä tiedosto

@@ -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
+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
+$_SERVER['APP_ENV']='helloworld';
19
+if (!isset($_SERVER['APP_ENV'])) {
20
+    if (!class_exists(Dotenv::class)) {
21
+        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.');
22
+    }
23
+    (new Dotenv())->load(__DIR__.'/../.env');
24
+}
25
+
26
+$input = new ArgvInput();
27
+$env = $input->getParameterOption(['--env', '-e'], $_SERVER['APP_ENV'] ?? 'dev');
28
+$debug = ($_SERVER['APP_DEBUG'] ?? ('prod' !== $env)) && !$input->hasParameterOption(['--no-debug', '']);
29
+
30
+if ($debug) {
31
+    umask(0000);
32
+
33
+    if (class_exists(Debug::class)) {
34
+        Debug::enable();
35
+    }
36
+}
37
+
38
+$kernel = new Kernel($env, $debug);
39
+$application = new Application($kernel);
40
+$application->run($input);

+ 48
- 0
composer.json Näytä tiedosto

@@ -0,0 +1,48 @@
1
+{
2
+    "name": "phpbenchmarks/symfony-4-0",
3
+    "license": "proprietary",
4
+    "type": "project",
5
+    "require": {
6
+        "php": "^7.1.3",
7
+        "phpbenchmarks/symfony": "1.0.0",
8
+        "symfony/console": "^4.0",
9
+        "symfony/flex": "^1.0",
10
+        "symfony/framework-bundle": "^4.0",
11
+        "symfony/lts": "^4@dev",
12
+        "symfony/serializer-pack": "^1.0",
13
+        "symfony/translation": "^4.0",
14
+        "symfony/yaml": "^4.0"
15
+    },
16
+    "config": {
17
+        "preferred-install": {
18
+            "*": "dist"
19
+        },
20
+        "sort-packages": true
21
+    },
22
+    "autoload": {
23
+        "psr-4": {
24
+            "App\\": "src/"
25
+        }
26
+    },
27
+    "scripts": {
28
+        "auto-scripts": {
29
+            "cache:clear": "symfony-cmd",
30
+            "assets:install --symlink --relative %PUBLIC_DIR%": "symfony-cmd"
31
+        },
32
+        "post-install-cmd": [
33
+            "@auto-scripts"
34
+        ],
35
+        "post-update-cmd": [
36
+            "@auto-scripts"
37
+        ]
38
+    },
39
+    "conflict": {
40
+        "symfony/symfony": "*"
41
+    },
42
+    "extra": {
43
+        "symfony": {
44
+            "id": "01C08XYTMWXHCW3KKR4WEESEAV",
45
+            "allow-contrib": false
46
+        }
47
+    }
48
+}

+ 2043
- 0
composer.lock
File diff suppressed because it is too large
Näytä tiedosto


+ 1342
- 0
composer.lock.php7.1
File diff suppressed because it is too large
Näytä tiedosto


+ 6
- 0
config/helloworld/bundles.php Näytä tiedosto

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

+ 7
- 0
config/helloworld/packages/framework.yaml Näytä tiedosto

@@ -0,0 +1,7 @@
1
+framework:
2
+    secret: '%env(APP_SECRET)%'
3
+    #default_locale: en
4
+    #http_method_override: true
5
+
6
+    php_errors:
7
+        log: true

+ 3
- 0
config/helloworld/packages/routing.yaml Näytä tiedosto

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

+ 2
- 0
config/helloworld/routes.yaml Näytä tiedosto

@@ -0,0 +1,2 @@
1
+helloworld:
2
+    resource: ../vendor/phpbenchmarks/symfony/Bundle/HelloWorldBundle/Resources/config/routing.yml

+ 6
- 0
config/rest/bundles.php Näytä tiedosto

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

+ 7
- 0
config/rest/packages/framework.yaml Näytä tiedosto

@@ -0,0 +1,7 @@
1
+framework:
2
+    secret: '%env(APP_SECRET)%'
3
+    #default_locale: en
4
+    #http_method_override: true
5
+
6
+    php_errors:
7
+        log: true

+ 3
- 0
config/rest/packages/routing.yaml Näytä tiedosto

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

+ 5
- 0
config/rest/packages/translation.yaml Näytä tiedosto

@@ -0,0 +1,5 @@
1
+framework:
2
+    default_locale: 'en'
3
+    translator:
4
+        fallbacks:
5
+            - 'en'

+ 2
- 0
config/rest/routes.yaml Näytä tiedosto

@@ -0,0 +1,2 @@
1
+rest:
2
+    resource: ../vendor/phpbenchmarks/symfony/Bundle/RestBundle/Resources/config/routing.yml

+ 3
- 0
config/routes/annotations.yaml Näytä tiedosto

@@ -0,0 +1,3 @@
1
+controllers:
2
+    resource: ../../src/Controller/
3
+    type: annotation

+ 12
- 0
public/helloworld.php Näytä tiedosto

@@ -0,0 +1,12 @@
1
+<?php
2
+
3
+use App\Kernel;
4
+use Symfony\Component\HttpFoundation\Request;
5
+
6
+require __DIR__ . '/../vendor/autoload.php';
7
+
8
+$kernel = new Kernel('helloworld', false);
9
+$request = Request::createFromGlobals();
10
+$response = $kernel->handle($request);
11
+$response->send();
12
+$kernel->terminate($request, $response);

+ 12
- 0
public/rest.php Näytä tiedosto

@@ -0,0 +1,12 @@
1
+<?php
2
+
3
+use App\Kernel;
4
+use Symfony\Component\HttpFoundation\Request;
5
+
6
+require __DIR__ . '/../vendor/autoload.php';
7
+
8
+$kernel = new Kernel('rest', true);
9
+$request = Request::createFromGlobals();
10
+$response = $kernel->handle($request);
11
+$response->send();
12
+$kernel->terminate($request, $response);

+ 68
- 0
src/Kernel.php Näytä tiedosto

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

+ 134
- 0
symfony.lock Näytä tiedosto

@@ -0,0 +1,134 @@
1
+{
2
+    "symfony/flex": {
3
+        "version": "1.0",
4
+        "recipe": {
5
+            "repo": "github.com/symfony/recipes",
6
+            "branch": "master",
7
+            "version": "1.0",
8
+            "ref": "e921bdbfe20cdefa3b82f379d1cd36df1bc8d115"
9
+        }
10
+    },
11
+    "symfony/polyfill-mbstring": {
12
+        "version": "v1.6.0"
13
+    },
14
+    "symfony/console": {
15
+        "version": "3.3",
16
+        "recipe": {
17
+            "repo": "github.com/symfony/recipes",
18
+            "branch": "master",
19
+            "version": "3.3",
20
+            "ref": "9f94d3ea453cd8a3b95db7f82592d7344fe3a76a"
21
+        }
22
+    },
23
+    "symfony/routing": {
24
+        "version": "3.3",
25
+        "recipe": {
26
+            "repo": "github.com/symfony/recipes",
27
+            "branch": "master",
28
+            "version": "3.3",
29
+            "ref": "a249484db698d1a847a30291c8f732414ac47e25"
30
+        }
31
+    },
32
+    "symfony/http-foundation": {
33
+        "version": "v4.0.0"
34
+    },
35
+    "symfony/event-dispatcher": {
36
+        "version": "v4.0.0"
37
+    },
38
+    "psr/log": {
39
+        "version": "1.0.2"
40
+    },
41
+    "symfony/debug": {
42
+        "version": "v4.0.0"
43
+    },
44
+    "symfony/http-kernel": {
45
+        "version": "v4.0.0"
46
+    },
47
+    "symfony/finder": {
48
+        "version": "v4.0.0"
49
+    },
50
+    "symfony/filesystem": {
51
+        "version": "v4.0.0"
52
+    },
53
+    "psr/container": {
54
+        "version": "1.0.0"
55
+    },
56
+    "symfony/dependency-injection": {
57
+        "version": "v4.0.0"
58
+    },
59
+    "symfony/config": {
60
+        "version": "v4.0.0"
61
+    },
62
+    "psr/simple-cache": {
63
+        "version": "1.0.0"
64
+    },
65
+    "psr/cache": {
66
+        "version": "1.0.1"
67
+    },
68
+    "symfony/cache": {
69
+        "version": "v4.0.0"
70
+    },
71
+    "symfony/framework-bundle": {
72
+        "version": "3.3",
73
+        "recipe": {
74
+            "repo": "github.com/symfony/recipes",
75
+            "branch": "master",
76
+            "version": "3.3",
77
+            "ref": "305b268e55e75059f20ec9827a8fd09a35c59866"
78
+        }
79
+    },
80
+    "symfony/lts": {
81
+        "version": "4-dev"
82
+    },
83
+    "symfony/yaml": {
84
+        "version": "v4.0.0"
85
+    },
86
+    "symfony/dotenv": {
87
+        "version": "v4.0.0"
88
+    },
89
+    "phpbenchmarks/benchmark-rest-data": {
90
+        "version": "1.0.0"
91
+    },
92
+    "phpbenchmarks/symfony": {
93
+        "version": "1.0.0"
94
+    },
95
+    "symfony/serializer": {
96
+        "version": "v4.0.0"
97
+    },
98
+    "symfony/inflector": {
99
+        "version": "v4.0.0"
100
+    },
101
+    "symfony/property-info": {
102
+        "version": "v4.0.0"
103
+    },
104
+    "symfony/property-access": {
105
+        "version": "v4.0.0"
106
+    },
107
+    "webmozart/assert": {
108
+        "version": "1.2.0"
109
+    },
110
+    "phpdocumentor/reflection-common": {
111
+        "version": "1.0.1"
112
+    },
113
+    "phpdocumentor/type-resolver": {
114
+        "version": "0.4.0"
115
+    },
116
+    "phpdocumentor/reflection-docblock": {
117
+        "version": "4.2.0"
118
+    },
119
+    "doctrine/lexer": {
120
+        "version": "v1.0.1"
121
+    },
122
+    "doctrine/annotations": {
123
+        "version": "1.0",
124
+        "recipe": {
125
+            "repo": "github.com/symfony/recipes",
126
+            "branch": "master",
127
+            "version": "1.0",
128
+            "ref": "cb4152ebcadbe620ea2261da1a1c5a9b8cea7672"
129
+        }
130
+    },
131
+    "symfony/serializer-pack": {
132
+        "version": "v1.0.0"
133
+    }
134
+}

Loading…
Peruuta
Tallenna