ソースを参照

Create helloworld branch

tags/3.1.0
Steevan BARBOYON 8年前
コミット
bd41126e73

+ 1
- 0
.gitignore ファイルの表示

@@ -1 +1,2 @@
1 1
 .idea/
2
+vendor/

+ 0
- 20
Bundle/RestBundle/Controller/RestController.php ファイルの表示

@@ -1,20 +0,0 @@
1
-<?php
2
-
3
-namespace PhpBenchmarksSymfony\Bundle\RestBundle\Controller;
4
-
5
-use PhpBenchmarksRestData\Service;
6
-use PhpBenchmarksSymfony\EventListener\DefineLocaleEventListener;
7
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
8
-use Symfony\Component\HttpFoundation\JsonResponse;
9
-use Symfony\Component\HttpFoundation\Response;
10
-
11
-class RestController extends Controller
12
-{
13
-    /** @return Response */
14
-    public function restAction()
15
-    {
16
-        $this->get('event_dispatcher')->dispatch(DefineLocaleEventListener::EVENT_NAME);
17
-
18
-        return new JsonResponse($this->get('serializer')->normalize(Service::getUsers(), 'json'));
19
-    }
20
-}

+ 0
- 21
Bundle/RestBundle/DependencyInjection/RestExtension.php ファイルの表示

@@ -1,21 +0,0 @@
1
-<?php
2
-
3
-namespace PhpBenchmarksSymfony\Bundle\RestBundle\DependencyInjection;
4
-
5
-use Symfony\Component\Config\FileLocator;
6
-use Symfony\Component\DependencyInjection\ContainerBuilder;
7
-use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
8
-use Symfony\Component\HttpKernel\DependencyInjection\Extension;
9
-
10
-class RestExtension extends Extension
11
-{
12
-    /**
13
-     * @param array $configs
14
-     * @param ContainerBuilder $container
15
-     */
16
-    public function load(array $configs, ContainerBuilder $container)
17
-    {
18
-        $loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
19
-        $loader->load('services.yml');
20
-    }
21
-}

+ 0
- 55
Bundle/RestBundle/Normalizer/CommentNormalizer.php ファイルの表示

@@ -1,55 +0,0 @@
1
-<?php
2
-
3
-namespace PhpBenchmarksSymfony\Bundle\RestBundle\Normalizer;
4
-
5
-use PhpBenchmarksRestData\Comment;
6
-use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
7
-use Symfony\Component\Serializer\SerializerAwareInterface;
8
-use Symfony\Component\Serializer\SerializerInterface;
9
-use Symfony\Component\Translation\TranslatorInterface;
10
-
11
-class CommentNormalizer implements NormalizerInterface, SerializerAwareInterface
12
-{
13
-    /** @var SerializerInterface */
14
-    protected $serializer;
15
-
16
-    /** @var TranslatorInterface */
17
-    protected $translator;
18
-
19
-    public function __construct(TranslatorInterface $translator)
20
-    {
21
-        $this->translator = $translator;
22
-    }
23
-
24
-    /** @param SerializerInterface $serializer */
25
-    public function setSerializer(SerializerInterface $serializer)
26
-    {
27
-        $this->serializer = $serializer;
28
-    }
29
-
30
-    /**
31
-     * @param mixed $data
32
-     * @param ?string $format
33
-     * @return bool
34
-     */
35
-    public function supportsNormalization($data, $format = null)
36
-    {
37
-        return $data instanceof Comment;
38
-    }
39
-
40
-    /**
41
-     * @param Comment $object
42
-     * @param ?string $format
43
-     * @param array $context
44
-     * @return array
45
-     */
46
-    public function normalize($object, $format = null, array $context = [])
47
-    {
48
-        return [
49
-            'id' => $object->getId(),
50
-            'message' => $object->getMessage(),
51
-            'translated' => $this->translator->trans('translated.2000', [], 'phpbenchmarks'),
52
-            'type' => $this->serializer->normalize($object->getType(), $format, $context)
53
-        ];
54
-    }
55
-}

+ 0
- 43
Bundle/RestBundle/Normalizer/CommentTypeNormalizer.php ファイルの表示

@@ -1,43 +0,0 @@
1
-<?php
2
-
3
-namespace PhpBenchmarksSymfony\Bundle\RestBundle\Normalizer;
4
-
5
-use PhpBenchmarksRestData\CommentType;
6
-use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
7
-use Symfony\Component\Translation\TranslatorInterface;
8
-
9
-class CommentTypeNormalizer implements NormalizerInterface
10
-{
11
-    /** @var TranslatorInterface */
12
-    protected $translator;
13
-
14
-    public function __construct(TranslatorInterface $translator)
15
-    {
16
-        $this->translator = $translator;
17
-    }
18
-
19
-    /**
20
-     * @param mixed $data
21
-     * @param ?string $format
22
-     * @return bool
23
-     */
24
-    public function supportsNormalization($data, $format = null)
25
-    {
26
-        return $data instanceof CommentType;
27
-    }
28
-
29
-    /**
30
-     * @param CommentType $object
31
-     * @param ?string $format
32
-     * @param array $context
33
-     * @return array
34
-     */
35
-    public function normalize($object, $format = null, array $context = [])
36
-    {
37
-        return [
38
-            'id' => $object->getId(),
39
-            'name' => $object->getName(),
40
-            'translated' => $this->translator->trans('translated.3000', [], 'phpbenchmarks'),
41
-        ];
42
-    }
43
-}

+ 0
- 56
Bundle/RestBundle/Normalizer/UserNormalizer.php ファイルの表示

@@ -1,56 +0,0 @@
1
-<?php
2
-
3
-namespace PhpBenchmarksSymfony\Bundle\RestBundle\Normalizer;
4
-
5
-use PhpBenchmarksRestData\User;
6
-use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
7
-use Symfony\Component\Serializer\SerializerAwareInterface;
8
-use Symfony\Component\Serializer\SerializerInterface;
9
-use Symfony\Component\Translation\TranslatorInterface;
10
-
11
-class UserNormalizer implements NormalizerInterface, SerializerAwareInterface
12
-{
13
-    /** @var SerializerInterface */
14
-    protected $serializer;
15
-
16
-    /** @var TranslatorInterface */
17
-    protected $translator;
18
-
19
-    public function __construct(TranslatorInterface $translator)
20
-    {
21
-        $this->translator = $translator;
22
-    }
23
-
24
-    /** @param SerializerInterface $serializer */
25
-    public function setSerializer(SerializerInterface $serializer)
26
-    {
27
-        $this->serializer = $serializer;
28
-    }
29
-
30
-    /**
31
-     * @param mixed $data
32
-     * @param ?string $format
33
-     * @return bool
34
-     */
35
-    public function supportsNormalization($data, $format = null)
36
-    {
37
-        return $data instanceof User;
38
-    }
39
-
40
-    /**
41
-     * @param User $object
42
-     * @param ?string $format
43
-     * @param array $context
44
-     * @return array
45
-     */
46
-    public function normalize($object, $format = null, array $context = [])
47
-    {
48
-        return [
49
-            'id' => $object->getId(),
50
-            'login' => $object->getLogin(),
51
-            'createdAt' => $object->getCreatedAt()->format('Y-m-d H:i:s'),
52
-            'translated' => $this->translator->trans('translated.1000', [], 'phpbenchmarks'),
53
-            'comments' => $this->serializer->normalize($object->getComments(), $format, $context)
54
-        ];
55
-    }
56
-}

+ 0
- 1500
Bundle/RestBundle/Resources/config/routing.yml
ファイル差分が大きすぎるため省略します
ファイルの表示


+ 0
- 27
Bundle/RestBundle/Resources/config/services.yml ファイルの表示

@@ -1,27 +0,0 @@
1
-services:
2
-    benchmark.normalizer.user:
3
-        class: PhpBenchmarksSymfony\Bundle\RestBundle\Normalizer\UserNormalizer
4
-        public: false
5
-        arguments: ['@translator']
6
-        tags:
7
-            - { name: serializer.normalizer }
8
-
9
-    benchmark.normalizer.comment:
10
-        class: PhpBenchmarksSymfony\Bundle\RestBundle\Normalizer\CommentNormalizer
11
-        public: false
12
-        arguments: ['@translator']
13
-        tags:
14
-            - { name: serializer.normalizer }
15
-
16
-    benchmark.normalizer.comment_type:
17
-        class: PhpBenchmarksSymfony\Bundle\RestBundle\Normalizer\CommentTypeNormalizer
18
-        public: false
19
-        arguments: ['@translator']
20
-        tags:
21
-            - { name: serializer.normalizer }
22
-
23
-    benchmark.event_listener.define_locale:
24
-        class: PhpBenchmarksSymfony\EventListener\DefineLocaleEventListener
25
-        arguments: ['@request_stack', '@translator']
26
-        tags:
27
-            - { name: kernel.event_listener, event: defineLocale }

+ 0
- 17
Bundle/RestBundle/RestBundle.php ファイルの表示

@@ -1,17 +0,0 @@
1
-<?php
2
-
3
-namespace PhpBenchmarksSymfony\Bundle\RestBundle;
4
-
5
-use PhpBenchmarksSymfony\DependencyInjection\CompilerPass\AddTranslationsPass;
6
-use Symfony\Component\DependencyInjection\ContainerBuilder;
7
-use Symfony\Component\HttpKernel\Bundle\Bundle;
8
-
9
-class RestBundle extends Bundle
10
-{
11
-    public function build(ContainerBuilder $container)
12
-    {
13
-        parent::build($container);
14
-
15
-        $container->addCompilerPass(new AddTranslationsPass());
16
-    }
17
-}

Bundle/HelloWorldBundle/Controller/HelloWorldController.php → Controller/HelloWorldController.php ファイルの表示

@@ -1,6 +1,6 @@
1 1
 <?php
2 2
 
3
-namespace PhpBenchmarksSymfony\Bundle\HelloWorldBundle\Controller;
3
+namespace PhpBenchmarksSymfony\HelloWorldBundle\Controller;
4 4
 
5 5
 use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6 6
 use Symfony\Component\HttpFoundation\Response;

+ 0
- 26
DependencyInjection/CompilerPass/AddTranslationsPass.php ファイルの表示

@@ -1,26 +0,0 @@
1
-<?php
2
-
3
-namespace PhpBenchmarksSymfony\DependencyInjection\CompilerPass;
4
-
5
-use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
-use Symfony\Component\DependencyInjection\ContainerBuilder;
7
-
8
-class AddTranslationsPass implements CompilerPassInterface
9
-{
10
-    public function process(ContainerBuilder $container)
11
-    {
12
-        $definition = $container->findDefinition('translator');
13
-        $definition->addMethodCall(
14
-            'addResource',
15
-            ['yml', __DIR__ . '/../../Translation/phpbenchmarks.en.yml', 'en', 'phpbenchmarks']
16
-        );
17
-        $definition->addMethodCall(
18
-            'addResource',
19
-            ['yml', __DIR__ . '/../../Translation/phpbenchmarks.en_GB.yml', 'en_GB', 'phpbenchmarks']
20
-        );
21
-        $definition->addMethodCall(
22
-            'addResource',
23
-            ['yml', __DIR__ . '/../../Translation/phpbenchmarks.fr_FR.yml', 'fr_FR', 'phpbenchmarks']
24
-        );
25
-    }
26
-}

+ 0
- 32
EventListener/DefineLocaleEventListener.php ファイルの表示

@@ -1,32 +0,0 @@
1
-<?php
2
-
3
-namespace PhpBenchmarksSymfony\EventListener;
4
-
5
-use Symfony\Component\HttpFoundation\RequestStack;
6
-use Symfony\Component\Translation\TranslatorInterface;
7
-
8
-class DefineLocaleEventListener
9
-{
10
-    const EVENT_NAME = 'defineLocale';
11
-
12
-    /** @var RequestStack */
13
-    protected $requestStack;
14
-
15
-    /** @var TranslatorInterface */
16
-    protected $translator;
17
-
18
-    public function __construct(RequestStack $requestStack, TranslatorInterface $translator)
19
-    {
20
-        $this->requestStack = $requestStack;
21
-        $this->translator = $translator;
22
-    }
23
-
24
-    public function onDefineLocale()
25
-    {
26
-        $locales = ['fr_FR', 'en_GB', 'aa_BB'];
27
-        $locale = $locales[rand(0, 2)];
28
-
29
-        $this->requestStack->getCurrentRequest()->setLocale($locale);
30
-        $this->translator->setLocale($locale);
31
-    }
32
-}

Bundle/HelloWorldBundle/HelloWorldBundle.php → HelloWorldBundle.php ファイルの表示

@@ -1,10 +1,9 @@
1 1
 <?php
2 2
 
3
-namespace PhpBenchmarksSymfony\Bundle\HelloWorldBundle;
3
+namespace PhpBenchmarksSymfony\HelloWorldBundle;
4 4
 
5 5
 use Symfony\Component\HttpKernel\Bundle\Bundle;
6 6
 
7 7
 class HelloWorldBundle extends Bundle
8 8
 {
9
-
10 9
 }

+ 28
- 4
README.md ファイルの表示

@@ -14,12 +14,36 @@ You can compare results between Apache Bench and Siege, PHP 5.6 to 7.2 and versi
14 14
 
15 15
 It's benchmark bundles for almost all Symfony versions.
16 16
 
17
-Symfony 2.0 to 2.3 : use [2.0 version](https://github.com/phpbenchmarks/symfony/tree/2.0).
17
+As Symfony change `request` service to `request_stack` in Symfony 2.4, branches has been created for Symfony <= 2.3.
18 18
 
19
-Symfony 2.4 to latest : use [1.0 version](https://github.com/phpbenchmarks/symfony).
19
+Hello World: [helloworld](https://github.com/phpbenchmarks/symfony/tree/helloworld)
20
+
21
+REST Api (Symfony 2.0 to 2.3): [restapi-symfony-2-3](https://github.com/phpbenchmarks/symfony/tree/restapi-symfony-2-3)
22
+
23
+REST Api (Symfony 2.4 to 4.x): [restapi](https://github.com/phpbenchmarks/symfony/tree/restapi)
24
+
25
+Blog: [blog](https://github.com/phpbenchmarks/symfony/tree/blog)
26
+
27
+Small overload (Symfony 2.0 to 2.3): [smalloverload-symfony-2-3](https://github.com/phpbenchmarks/symfony/tree/smalloverload-symfony-2-3)
28
+
29
+Small overload (Symfony 2.4 to 4.x): [smalloverload](https://github.com/phpbenchmarks/symfony/tree/smalloverload)
30
+
31
+Big overload (Symfony 2.0 to 2.3): [bigoverload-symfony-2-3](https://github.com/phpbenchmarks/symfony/tree/bigoverload-symfony-2-3)
32
+
33
+Big overload (Symfony 2.4 to 4.x): [bigoverload](https://github.com/phpbenchmarks/symfony/tree/bigoverload)
20 34
 
21 35
 You can find how we benchmark it [here](http://www.phpbenchmarks.com/en/benchmark-protocol).
22 36
 
23
-## Symfony
37
+## How version works ?
38
+
39
+We do not follow semantic version for this repository. Here is an explanation about our versioning system:
40
+
41
+`X` benchmark type (`1` Hello World, `2` Blog, `3` REST Api, `4` Small overload, `5` Big overload)
42
+
43
+`Y` related to Symfony version (`0` Symfony 2.0 to 2.3, `1` Symfony 3.4 to 4.x for `REST Api` benchmak for example)
44
+
45
+`Z` new version, not just bugfix and could contains BC
46
+
47
+## Symfony benchmarks
24 48
 
25
-You can find all Symfony benchmarks [here](http://www.phpbenchmarks.com/fr/benchmark/apache-bench/php-7.1/select-version/symfony.html).
49
+You can find all Symfony benchmarks [here](http://www.phpbenchmarks.com/en/benchmark/apache-bench/php-7.2/select-version/symfony.html).

Bundle/HelloWorldBundle/Resources/config/routing.yml → Resources/config/routing.yml ファイルの表示


+ 0
- 5000
Translation/phpbenchmarks.en.yml
ファイル差分が大きすぎるため省略します
ファイルの表示


+ 0
- 5000
Translation/phpbenchmarks.en_GB.yml
ファイル差分が大きすぎるため省略します
ファイルの表示


+ 0
- 5000
Translation/phpbenchmarks.fr_FR.yml
ファイル差分が大きすぎるため省略します
ファイルの表示


+ 2
- 3
composer.json ファイルの表示

@@ -4,11 +4,10 @@
4 4
     "type": "project",
5 5
     "autoload": {
6 6
         "psr-4": {
7
-            "PhpBenchmarksSymfony\\": ""
7
+            "PhpBenchmarksSymfony\\HelloWorldBundle\\": ""
8 8
         }
9 9
     },
10 10
     "require": {
11
-        "php": ">=5.4.0",
12
-        "phpbenchmarks/benchmark-rest-data": "1.0.0"
11
+        "php": ">=5.4.0"
13 12
     }
14 13
 }

読み込み中…
キャンセル
保存