├── .editorconfig ├── .gitignore ├── .travis.yml ├── Dockerfile ├── LICENSE ├── README.md ├── app ├── .htaccess ├── AppCache.php ├── AppKernel.php ├── Resources │ └── views │ │ ├── base.html.twig │ │ └── default │ │ └── index.html.twig ├── autoload.php └── config │ ├── config.yml │ ├── config_dev.yml │ ├── config_prod.yml │ ├── config_test.yml │ ├── parameters.yml.dist │ ├── routing.yml │ ├── routing_dev.yml │ ├── security.yml │ └── services.yml ├── bin ├── console └── symfony_requirements ├── composer.json ├── composer.lock ├── docker-compose.yml ├── phpunit.xml.dist ├── src ├── .htaccess └── AppBundle │ ├── AppBundle.php │ ├── DataFixtures │ └── ORM │ │ ├── LoadCharacterData.php │ │ ├── LoadFakeFactionWithManyShipsData.php │ │ └── LoadShipAndFactionData.php │ ├── DependencyInjection │ └── AppExtension.php │ ├── Entity │ ├── Character.php │ ├── Faction.php │ ├── FromArrayTrait.php │ ├── Repository │ │ └── ShipRepository.php │ └── Ship.php │ ├── GraphQL │ ├── Relay │ │ ├── Mutation │ │ │ └── ShipMutation.php │ │ └── Resolver │ │ │ ├── FactionResolver.php │ │ │ └── NodeResolver.php │ └── Resolver │ │ └── CharacterResolver.php │ └── Resources │ └── config │ ├── doctrine │ ├── Character.orm.xml │ ├── Faction.orm.xml │ └── Ship.orm.xml │ ├── graphql-relay.yml │ ├── graphql.yml │ └── graphql │ ├── Character.types.yml │ ├── Droid.types.yml │ ├── Episode.types.yml │ ├── Human.types.yml │ ├── Mutation.types.yml │ ├── Query.types.yml │ └── relay │ ├── Faction.types.yml │ ├── IntroduceShipMutation.types.yml │ ├── Node.types.yml │ ├── Ship.types.yml │ └── ShipConnection.types.yml ├── tests └── AppBundle │ └── Functional │ ├── Relay │ ├── StarWarsConnectionTest.php │ ├── StarWarsMutationTest.php │ └── StarWarsObjectIdentificationTest.php │ ├── StarWarsQueryTest.php │ └── WebTestCase.php ├── var ├── SymfonyRequirements.php ├── cache │ └── .gitkeep ├── logs │ └── .gitkeep └── sessions │ └── .gitkeep └── web ├── .htaccess ├── app.php ├── app_dev.php ├── apple-touch-icon.png ├── config.php ├── favicon.ico └── robots.txt /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_size = 2 7 | indent_style = space 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | indent_size = 4 13 | trim_trailing_whitespace = false 14 | 15 | [*.mk,Makefile] 16 | indent_style = tab 17 | 18 | [*.{php,yml,yaml}] 19 | indent_size = 4 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /app/config/parameters.yml 2 | /build/ 3 | /phpunit.xml 4 | /var/* 5 | !/var/cache 6 | /var/cache/* 7 | !var/cache/.gitkeep 8 | !/var/logs 9 | /var/logs/* 10 | !var/logs/.gitkeep 11 | !/var/sessions 12 | /var/sessions/* 13 | !var/sessions/.gitkeep 14 | !var/SymfonyRequirements.php 15 | /vendor/ 16 | /web/bundles/ 17 | /bin/ 18 | !/bin/console 19 | !/bin/symfony_requirements 20 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | 3 | php: 4 | - 5.6 5 | 6 | services: 7 | - mysql 8 | 9 | branches: 10 | only: 11 | - master 12 | - /^\d+\.\d+$/ 13 | 14 | matrix: 15 | fast_finish: true 16 | 17 | cache: 18 | directories: 19 | - $HOME/.composer/cache 20 | 21 | before_install: 22 | - phpenv config-rm xdebug.ini 23 | - composer selfupdate 24 | 25 | install: composer update --prefer-dist --no-interaction 26 | 27 | before_script: 28 | - mysql -e 'create database starwars_test;' 29 | 30 | script: bin/phpunit 31 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM vincentchalamon/symfony 2 | 3 | RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \ 4 | && curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$version \ 5 | && tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp \ 6 | && mv /tmp/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so \ 7 | && printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8707\n" > /etc/php5/cli/conf.d/blackfire.ini \ 8 | && printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8707\n" > /etc/php5/fpm/conf.d/blackfire.ini 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | McG-web/Graphql-Symfony-Doctrine-Sandbox 2 | ======================================== 3 | 4 | [![Build Status](https://travis-ci.org/mcg-web/graphql-symfony-doctrine-sandbox.svg?branch=master)](https://travis-ci.org/mcg-web/graphql-symfony-doctrine-sandbox) 5 | 6 | Installation 7 | ------------- 8 | 9 | ```bash 10 | composer create-project mcg-web/graphql-symfony-doctrine-sandbox --stability dev 11 | ``` 12 | 13 | Usage 14 | ------ 15 | 16 | Using docker compose 17 | 18 | ```bash 19 | docker-compose up -d 20 | ``` 21 | 22 | Create database and load fixtures 23 | 24 | ```bash 25 | docker exec -it graphqlsymfonydoctrinesandbox_web_1 bash 26 | bin/console doctrine:database:create 27 | bin/console doctrine:schema:create 28 | bin/console doctrine:fixtures:load 29 | ``` 30 | 31 | Endpoints 32 | --------- 33 | 34 | - **GraphiQL :** http://127.0.0.1/graphiql 35 | - **GraphQL :** http://127.0.0.1/ 36 | -------------------------------------------------------------------------------- /app/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | Require all denied 3 | 4 | 5 | Order deny,allow 6 | Deny from all 7 | 8 | -------------------------------------------------------------------------------- /app/AppCache.php: -------------------------------------------------------------------------------- 1 | getEnvironment(), ['dev', 'test'], true)) { 22 | $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle(); 23 | $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(); 24 | $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle(); 25 | $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle(); 26 | $bundles[] = new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(); 27 | $bundles[] = new Liip\FunctionalTestBundle\LiipFunctionalTestBundle(); 28 | } 29 | 30 | return $bundles; 31 | } 32 | 33 | public function getRootDir() 34 | { 35 | return __DIR__; 36 | } 37 | 38 | public function getCacheDir() 39 | { 40 | return dirname(__DIR__).'/var/cache/'.$this->getEnvironment(); 41 | } 42 | 43 | public function getLogDir() 44 | { 45 | return dirname(__DIR__).'/var/logs'; 46 | } 47 | 48 | public function registerContainerConfiguration(LoaderInterface $loader) 49 | { 50 | $loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml'); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /app/Resources/views/base.html.twig: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {% block title %}Welcome!{% endblock %} 6 | {% block stylesheets %}{% endblock %} 7 | 8 | 9 | 10 | {% block body %}{% endblock %} 11 | {% block javascripts %}{% endblock %} 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/Resources/views/default/index.html.twig: -------------------------------------------------------------------------------- 1 | {% extends 'base.html.twig' %} 2 | 3 | {% block body %} 4 |
5 |
6 |
7 |

Welcome to Symfony {{ constant('Symfony\\Component\\HttpKernel\\Kernel::VERSION') }}

8 |
9 | 10 |
11 |

12 | 13 | 14 | Your application is now ready. You can start working on it at: 15 | {{ base_dir }}/ 16 |

17 |
18 | 19 | 44 | 45 |
46 |
47 | {% endblock %} 48 | 49 | {% block stylesheets %} 50 | 76 | {% endblock %} 77 | -------------------------------------------------------------------------------- /app/autoload.php: -------------------------------------------------------------------------------- 1 | getParameterOption(['--env', '-e'], getenv('SYMFONY_ENV') ?: 'dev'); 21 | $debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(['--no-debug', '']) && $env !== 'prod'; 22 | 23 | if ($debug) { 24 | Debug::enable(); 25 | } 26 | 27 | $kernel = new AppKernel($env, $debug); 28 | $application = new Application($kernel); 29 | $application->run($input); 30 | -------------------------------------------------------------------------------- /bin/symfony_requirements: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | getPhpIniConfigPath(); 9 | 10 | echo_title('Symfony Requirements Checker'); 11 | 12 | echo '> PHP is using the following php.ini file:'.PHP_EOL; 13 | if ($iniPath) { 14 | echo_style('green', ' '.$iniPath); 15 | } else { 16 | echo_style('yellow', ' WARNING: No configuration file (php.ini) used by PHP!'); 17 | } 18 | 19 | echo PHP_EOL.PHP_EOL; 20 | 21 | echo '> Checking Symfony requirements:'.PHP_EOL.' '; 22 | 23 | $messages = array(); 24 | foreach ($symfonyRequirements->getRequirements() as $req) { 25 | if ($helpText = get_error_message($req, $lineSize)) { 26 | echo_style('red', 'E'); 27 | $messages['error'][] = $helpText; 28 | } else { 29 | echo_style('green', '.'); 30 | } 31 | } 32 | 33 | $checkPassed = empty($messages['error']); 34 | 35 | foreach ($symfonyRequirements->getRecommendations() as $req) { 36 | if ($helpText = get_error_message($req, $lineSize)) { 37 | echo_style('yellow', 'W'); 38 | $messages['warning'][] = $helpText; 39 | } else { 40 | echo_style('green', '.'); 41 | } 42 | } 43 | 44 | if ($checkPassed) { 45 | echo_block('success', 'OK', 'Your system is ready to run Symfony projects'); 46 | } else { 47 | echo_block('error', 'ERROR', 'Your system is not ready to run Symfony projects'); 48 | 49 | echo_title('Fix the following mandatory requirements', 'red'); 50 | 51 | foreach ($messages['error'] as $helpText) { 52 | echo ' * '.$helpText.PHP_EOL; 53 | } 54 | } 55 | 56 | if (!empty($messages['warning'])) { 57 | echo_title('Optional recommendations to improve your setup', 'yellow'); 58 | 59 | foreach ($messages['warning'] as $helpText) { 60 | echo ' * '.$helpText.PHP_EOL; 61 | } 62 | } 63 | 64 | echo PHP_EOL; 65 | echo_style('title', 'Note'); 66 | echo ' The command console could use a different php.ini file'.PHP_EOL; 67 | echo_style('title', '~~~~'); 68 | echo ' than the one used with your web server. To be on the'.PHP_EOL; 69 | echo ' safe side, please check the requirements from your web'.PHP_EOL; 70 | echo ' server using the '; 71 | echo_style('yellow', 'web/config.php'); 72 | echo ' script.'.PHP_EOL; 73 | echo PHP_EOL; 74 | 75 | exit($checkPassed ? 0 : 1); 76 | 77 | function get_error_message(Requirement $requirement, $lineSize) 78 | { 79 | if ($requirement->isFulfilled()) { 80 | return; 81 | } 82 | 83 | $errorMessage = wordwrap($requirement->getTestMessage(), $lineSize - 3, PHP_EOL.' ').PHP_EOL; 84 | $errorMessage .= ' > '.wordwrap($requirement->getHelpText(), $lineSize - 5, PHP_EOL.' > ').PHP_EOL; 85 | 86 | return $errorMessage; 87 | } 88 | 89 | function echo_title($title, $style = null) 90 | { 91 | $style = $style ?: 'title'; 92 | 93 | echo PHP_EOL; 94 | echo_style($style, $title.PHP_EOL); 95 | echo_style($style, str_repeat('~', strlen($title)).PHP_EOL); 96 | echo PHP_EOL; 97 | } 98 | 99 | function echo_style($style, $message) 100 | { 101 | // ANSI color codes 102 | $styles = array( 103 | 'reset' => "\033[0m", 104 | 'red' => "\033[31m", 105 | 'green' => "\033[32m", 106 | 'yellow' => "\033[33m", 107 | 'error' => "\033[37;41m", 108 | 'success' => "\033[37;42m", 109 | 'title' => "\033[34m", 110 | ); 111 | $supports = has_color_support(); 112 | 113 | echo($supports ? $styles[$style] : '').$message.($supports ? $styles['reset'] : ''); 114 | } 115 | 116 | function echo_block($style, $title, $message) 117 | { 118 | $message = ' '.trim($message).' '; 119 | $width = strlen($message); 120 | 121 | echo PHP_EOL.PHP_EOL; 122 | 123 | echo_style($style, str_repeat(' ', $width)); 124 | echo PHP_EOL; 125 | echo_style($style, str_pad(' ['.$title.']', $width, ' ', STR_PAD_RIGHT)); 126 | echo PHP_EOL; 127 | echo_style($style, $message); 128 | echo PHP_EOL; 129 | echo_style($style, str_repeat(' ', $width)); 130 | echo PHP_EOL; 131 | } 132 | 133 | function has_color_support() 134 | { 135 | static $support; 136 | 137 | if (null === $support) { 138 | if (DIRECTORY_SEPARATOR == '\\') { 139 | $support = false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI'); 140 | } else { 141 | $support = function_exists('posix_isatty') && @posix_isatty(STDOUT); 142 | } 143 | } 144 | 145 | return $support; 146 | } 147 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mcg-web/graphql-symfony-doctrine-sandbox", 3 | "license": "MIT", 4 | "type": "project", 5 | "config" : { 6 | "bin-dir": "bin", 7 | "platform": {"php": "5.6"}, 8 | "sort-packages": true 9 | }, 10 | "autoload": { 11 | "psr-4": { 12 | "": "src/" 13 | }, 14 | "classmap": [ 15 | "app/AppKernel.php", 16 | "app/AppCache.php" 17 | ] 18 | }, 19 | "autoload-dev": { 20 | "psr-4": { 21 | "Tests\\": "tests/" 22 | } 23 | }, 24 | "require": { 25 | "php": ">=5.5.9", 26 | "symfony/symfony": "3.4.*", 27 | "doctrine/orm": "^2.5", 28 | "doctrine/doctrine-bundle": "^1.6", 29 | "doctrine/doctrine-cache-bundle": "^1.2", 30 | "symfony/monolog-bundle": "^2.8", 31 | "sensio/distribution-bundle": "^5.0", 32 | "sensio/framework-extra-bundle": "^3.0.2", 33 | "incenteev/composer-parameter-handler": "^2.0", 34 | "overblog/graphql-bundle": "^0.9.0", 35 | "twig/twig": "^1.30" 36 | }, 37 | "require-dev": { 38 | "sensio/generator-bundle": "^3.0", 39 | "symfony/phpunit-bridge": "^3.4", 40 | "doctrine/doctrine-fixtures-bundle": "^2.3", 41 | "phpunit/phpunit": "^4.1|^5.1", 42 | "liip/functional-test-bundle": "^1.5" 43 | }, 44 | "scripts": { 45 | "post-install-cmd": [ 46 | "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters", 47 | "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap", 48 | "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache", 49 | "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets", 50 | "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile", 51 | "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget" 52 | ], 53 | "post-update-cmd": [ 54 | "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters", 55 | "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap", 56 | "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache", 57 | "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets", 58 | "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile", 59 | "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget" 60 | ] 61 | }, 62 | "extra": { 63 | "symfony-app-dir": "app", 64 | "symfony-bin-dir": "bin", 65 | "symfony-var-dir": "var", 66 | "symfony-web-dir": "web", 67 | "symfony-tests-dir": "tests", 68 | "symfony-assets-install": "relative", 69 | "incenteev-parameters": { 70 | "file": "app/config/parameters.yml" 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "2" 2 | 3 | services: 4 | web: 5 | build: . 6 | volumes: 7 | - .:/var/www 8 | networks: 9 | - graphql-sandbox 10 | tty: true 11 | ports: 12 | - "80:80" 13 | 14 | mysql: 15 | image: mysql 16 | environment: 17 | MYSQL_USER: root 18 | MYSQL_ALLOW_EMPTY_PASSWORD: 'yes' 19 | networks: 20 | - graphql-sandbox 21 | 22 | blackfire: 23 | image: blackfire/blackfire 24 | environment: 25 | - BLACKFIRE_SERVER_ID 26 | - BLACKFIRE_SERVER_TOKEN 27 | - BLACKFIRE_CLIENT_ID 28 | - BLACKFIRE_CLIENT_TOKEN 29 | networks: 30 | - graphql-sandbox 31 | 32 | 33 | networks: 34 | graphql-sandbox: 35 | driver: bridge 36 | -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | tests 18 | 19 | 20 | 21 | 22 | 23 | src 24 | 25 | src/*Bundle/Resources 26 | src/*/*Bundle/Resources 27 | src/*/Bundle/*Bundle/Resources 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | Require all denied 3 | 4 | 5 | Order deny,allow 6 | Deny from all 7 | 8 | -------------------------------------------------------------------------------- /src/AppBundle/AppBundle.php: -------------------------------------------------------------------------------- 1 | loadCharacters($manager, StarWarsData::humans(), Character::TYPE_HUMAN); 21 | $this->loadCharacters($manager, StarWarsData::droids(), Character::TYPE_DROID); 22 | $this->loadFriends($manager, array_merge(StarWarsData::humans(), StarWarsData::droids())); 23 | } 24 | 25 | private function loadCharacters(ObjectManager $manager, array $characters, $type) 26 | { 27 | foreach ($characters as $data) { 28 | unset($data['friends']); 29 | $data['type'] = $type; 30 | 31 | $character = new Character(); 32 | $character->fromArray($data); 33 | 34 | $manager->persist($character); 35 | $metadata = $manager->getClassMetaData(get_class($character)); 36 | $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE); 37 | $manager->flush(); 38 | 39 | $this->characters[$character->getId()] = $character; 40 | } 41 | } 42 | 43 | private function loadFriends(ObjectManager $manager, array $characters) 44 | { 45 | foreach ($characters as $data) { 46 | $character = $this->characters[$data['id']]; 47 | foreach ($data['friends'] as $friendId) { 48 | $friend = $this->characters[$friendId]; 49 | $character->addFriend($friend); 50 | } 51 | $manager->persist($character); 52 | $manager->flush(); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/AppBundle/DataFixtures/ORM/LoadFakeFactionWithManyShipsData.php: -------------------------------------------------------------------------------- 1 | loadFaction($manager); 16 | $this->loadShips($manager, $faction); 17 | } 18 | 19 | private function loadShips(ObjectManager $manager, Faction $faction) 20 | { 21 | for ($i = 0; $i < 1000; ++$i) { 22 | $ship = new Ship(); 23 | $ship->setId(9 + $i); 24 | $ship->setName('Fake ship '.$i); 25 | $faction->addShip($ship); 26 | 27 | $manager->persist($faction); 28 | $manager->persist($ship); 29 | $metadata = $manager->getClassMetaData(get_class($ship)); 30 | $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE); 31 | $manager->flush(); 32 | } 33 | } 34 | 35 | private function loadFaction(ObjectManager $manager) 36 | { 37 | $faction = new Faction(); 38 | $faction->fromArray([ 39 | 'id' => '3', 40 | 'name' => 'Fake Faction', 41 | 'type' => Faction::TYPE_FAKE, 42 | ]); 43 | $manager->persist($faction); 44 | $metadata = $manager->getClassMetaData(get_class($faction)); 45 | $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE); 46 | $manager->flush(); 47 | 48 | return $faction; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/AppBundle/DataFixtures/ORM/LoadShipAndFactionData.php: -------------------------------------------------------------------------------- 1 | [ 15 | [ 16 | 'id' => '1', 17 | 'name' => 'X-Wing', 18 | ], 19 | [ 20 | 'id' => '2', 21 | 'name' => 'Y-Wing', 22 | ], 23 | [ 24 | 'id' => '3', 25 | 'name' => 'A-Wing', 26 | ], 27 | [ 28 | 'id' => '4', 29 | 'name' => 'Millenium Falcon', 30 | ], 31 | [ 32 | 'id' => '5', 33 | 'name' => 'Home One', 34 | ], 35 | [ 36 | 'id' => '6', 37 | 'name' => 'TIE Fighter', 38 | ], 39 | [ 40 | 'id' => '7', 41 | 'name' => 'TIE Interceptor', 42 | ], 43 | [ 44 | 'id' => '8', 45 | 'name' => 'Executor', 46 | ], 47 | ], 48 | 'factions' => [ 49 | [ 50 | 'id' => '1', 51 | 'name' => 'Alliance to Restore the Republic', 52 | 'ships' => ['1', '2', '3', '4', '5'], 53 | 'type' => Faction::TYPE_REBELS, 54 | ], 55 | [ 56 | 'id' => '2', 57 | 'name' => 'Galactic Empire', 58 | 'type' => Faction::TYPE_EMPIRE, 59 | 'ships' => ['6', '7', '8'], 60 | ], 61 | ], 62 | ]; 63 | 64 | /** @var Ship[] */ 65 | private $ships = []; 66 | 67 | public function load(ObjectManager $manager) 68 | { 69 | $this->loadShips($manager, $this->data['ships']); 70 | $this->loadFactions($manager, $this->data['factions']); 71 | } 72 | 73 | private function loadShips(ObjectManager $manager, array $ships) 74 | { 75 | foreach ($ships as $data) { 76 | $ship = new Ship(); 77 | $ship->fromArray($data); 78 | 79 | $manager->persist($ship); 80 | $metadata = $manager->getClassMetaData(get_class($ship)); 81 | $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE); 82 | $manager->flush(); 83 | 84 | $this->ships[$ship->getId()] = $ship; 85 | } 86 | } 87 | 88 | private function loadFactions(ObjectManager $manager, array $factions) 89 | { 90 | foreach ($factions as $data) { 91 | $ships = $data['ships']; 92 | unset($data['ships']); 93 | $faction = new Faction(); 94 | $faction->fromArray($data); 95 | foreach ($ships as $shipId) { 96 | $faction->addShip($this->ships[$shipId]); 97 | } 98 | $manager->persist($faction); 99 | $metadata = $manager->getClassMetaData(get_class($faction)); 100 | $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE); 101 | $manager->flush(); 102 | } 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /src/AppBundle/DependencyInjection/AppExtension.php: -------------------------------------------------------------------------------- 1 | load('graphql.yml'); 16 | $loader->load('graphql-relay.yml'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/AppBundle/Entity/Character.php: -------------------------------------------------------------------------------- 1 | friends = new ArrayCollection(); 58 | } 59 | 60 | /** 61 | * Add friend. 62 | * 63 | * @param Character $friend 64 | * 65 | * @return Character 66 | */ 67 | public function addFriend(Character $friend) 68 | { 69 | $this->friends[] = $friend; 70 | 71 | return $this; 72 | } 73 | 74 | /** 75 | * Remove friend. 76 | * 77 | * @param Character $friend 78 | */ 79 | public function removeFriend(Character $friend) 80 | { 81 | $this->friends->removeElement($friend); 82 | } 83 | 84 | /** 85 | * Get friends. 86 | * 87 | * @return \Doctrine\Common\Collections\Collection 88 | */ 89 | public function getFriends() 90 | { 91 | return $this->friends; 92 | } 93 | 94 | /** 95 | * Get id. 96 | * 97 | * @return int 98 | */ 99 | public function getId() 100 | { 101 | return $this->id; 102 | } 103 | 104 | /** 105 | * @param int $id 106 | * 107 | * @return $this 108 | */ 109 | public function setId($id) 110 | { 111 | $this->id = $id; 112 | 113 | return $this; 114 | } 115 | 116 | /** 117 | * Set name. 118 | * 119 | * @param string $name 120 | * 121 | * @return Character 122 | */ 123 | public function setName($name) 124 | { 125 | $this->name = $name; 126 | 127 | return $this; 128 | } 129 | 130 | /** 131 | * Get name. 132 | * 133 | * @return string 134 | */ 135 | public function getName() 136 | { 137 | return $this->name; 138 | } 139 | 140 | /** 141 | * Set homePlanet. 142 | * 143 | * @param string $homePlanet 144 | * 145 | * @return Character 146 | */ 147 | public function setHomePlanet($homePlanet) 148 | { 149 | $this->homePlanet = $homePlanet; 150 | 151 | return $this; 152 | } 153 | 154 | /** 155 | * Get homePlanet. 156 | * 157 | * @return string 158 | */ 159 | public function getHomePlanet() 160 | { 161 | return $this->homePlanet; 162 | } 163 | 164 | /** 165 | * Set type. 166 | * 167 | * @param string $type 168 | * 169 | * @return Character 170 | */ 171 | public function setType($type) 172 | { 173 | $this->type = $type; 174 | 175 | return $this; 176 | } 177 | 178 | /** 179 | * Get type. 180 | * 181 | * @return string 182 | */ 183 | public function getType() 184 | { 185 | return $this->type; 186 | } 187 | 188 | /** 189 | * @return string 190 | */ 191 | public function getPrimaryFunction() 192 | { 193 | return $this->primaryFunction; 194 | } 195 | 196 | /** 197 | * @param string $primaryFunction 198 | * 199 | * @return Character 200 | */ 201 | public function setPrimaryFunction($primaryFunction) 202 | { 203 | $this->primaryFunction = $primaryFunction; 204 | 205 | return $this; 206 | } 207 | 208 | /** 209 | * Set appearsIn. 210 | * 211 | * @param array $appearsIn 212 | * 213 | * @return Character 214 | */ 215 | public function setAppearsIn($appearsIn) 216 | { 217 | $this->appearsIn = $appearsIn; 218 | 219 | return $this; 220 | } 221 | 222 | /** 223 | * Get appearsIn. 224 | * 225 | * @return array 226 | */ 227 | public function getAppearsIn() 228 | { 229 | return $this->appearsIn; 230 | } 231 | } 232 | -------------------------------------------------------------------------------- /src/AppBundle/Entity/Faction.php: -------------------------------------------------------------------------------- 1 | ships = new ArrayCollection(); 44 | } 45 | 46 | /** 47 | * Get id. 48 | * 49 | * @return int 50 | */ 51 | public function getId() 52 | { 53 | return $this->id; 54 | } 55 | 56 | /** 57 | * @param int $id 58 | * 59 | * @return $this 60 | */ 61 | public function setId($id) 62 | { 63 | $this->id = $id; 64 | 65 | return $this; 66 | } 67 | 68 | /** 69 | * Set name. 70 | * 71 | * @param string $name 72 | * 73 | * @return Faction 74 | */ 75 | public function setName($name) 76 | { 77 | $this->name = $name; 78 | 79 | return $this; 80 | } 81 | 82 | /** 83 | * Get name. 84 | * 85 | * @return string 86 | */ 87 | public function getName() 88 | { 89 | return $this->name; 90 | } 91 | 92 | /** 93 | * Add ship. 94 | * 95 | * @param Ship $ship 96 | * 97 | * @return Faction 98 | */ 99 | public function addShip(Ship $ship) 100 | { 101 | $this->ships[] = $ship; 102 | 103 | return $this; 104 | } 105 | 106 | /** 107 | * Remove ship. 108 | * 109 | * @param Ship $ship 110 | */ 111 | public function removeShip(Ship $ship) 112 | { 113 | $this->ships->removeElement($ship); 114 | } 115 | 116 | /** 117 | * Get ships. 118 | * 119 | * @return \Doctrine\Common\Collections\Collection 120 | */ 121 | public function getShips() 122 | { 123 | return $this->ships; 124 | } 125 | 126 | /** 127 | * Set type. 128 | * 129 | * @param string $type 130 | * 131 | * @return Faction 132 | */ 133 | public function setType($type) 134 | { 135 | $this->type = $type; 136 | 137 | return $this; 138 | } 139 | 140 | /** 141 | * Get type. 142 | * 143 | * @return string 144 | */ 145 | public function getType() 146 | { 147 | return $this->type; 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /src/AppBundle/Entity/FromArrayTrait.php: -------------------------------------------------------------------------------- 1 | $value) { 12 | Resolver::setObjectOrArrayValue($this, $property, $value); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/AppBundle/Entity/Repository/ShipRepository.php: -------------------------------------------------------------------------------- 1 | shipByFactionIdQueryBuilder($factionId) 12 | ->select('COUNT(s)') 13 | ->getQuery() 14 | ->getSingleScalarResult() 15 | ; 16 | } 17 | 18 | public function retrieveShipsByFactionId($factionId, $offset = 0, $limit = 0) 19 | { 20 | $qb = $this->shipByFactionIdQueryBuilder($factionId); 21 | 22 | if ($limit > 0) { 23 | $qb->setMaxResults($limit); 24 | } 25 | 26 | return $ships = $qb->select('s') 27 | ->setFirstResult($offset) 28 | ->getQuery() 29 | ->getResult(); 30 | } 31 | 32 | private function shipByFactionIdQueryBuilder($factionId) 33 | { 34 | $qb = $this->createQueryBuilder('s') 35 | ->innerJoin('s.factions', 'f') 36 | ->where('f.id = :faction_id') 37 | ->setParameter('faction_id', $factionId) 38 | ; 39 | 40 | return $qb; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/AppBundle/Entity/Ship.php: -------------------------------------------------------------------------------- 1 | factions = new ArrayCollection(); 35 | } 36 | 37 | /** 38 | * Get id. 39 | * 40 | * @return int 41 | */ 42 | public function getId() 43 | { 44 | return $this->id; 45 | } 46 | 47 | /** 48 | * @param int $id 49 | * 50 | * @return $this 51 | */ 52 | public function setId($id) 53 | { 54 | $this->id = $id; 55 | 56 | return $this; 57 | } 58 | 59 | /** 60 | * Set name. 61 | * 62 | * @param string $name 63 | * 64 | * @return Ship 65 | */ 66 | public function setName($name) 67 | { 68 | $this->name = $name; 69 | 70 | return $this; 71 | } 72 | 73 | /** 74 | * Get name. 75 | * 76 | * @return string 77 | */ 78 | public function getName() 79 | { 80 | return $this->name; 81 | } 82 | 83 | /** 84 | * Add faction. 85 | * 86 | * @param Faction $faction 87 | * 88 | * @return Ship 89 | */ 90 | public function addFaction(Faction $faction) 91 | { 92 | $this->factions[] = $faction; 93 | 94 | return $this; 95 | } 96 | 97 | /** 98 | * Remove faction. 99 | * 100 | * @param Faction $faction 101 | */ 102 | public function removeFaction(Faction $faction) 103 | { 104 | $this->factions->removeElement($faction); 105 | } 106 | 107 | /** 108 | * Get factions. 109 | * 110 | * @return \Doctrine\Common\Collections\Collection 111 | */ 112 | public function getFactions() 113 | { 114 | return $this->factions; 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /src/AppBundle/GraphQL/Relay/Mutation/ShipMutation.php: -------------------------------------------------------------------------------- 1 | container->get('doctrine.orm.default_entity_manager'); 18 | 19 | $faction = $em->find('AppBundle:Faction', $factionId); 20 | if (!$faction instanceof Faction) { 21 | throw new UserError(sprintf('Unknown faction with id "%d"', $factionId)); 22 | } 23 | 24 | $ship = new Ship(); 25 | $ship->setName($shipName); 26 | $ship->addFaction($faction); 27 | 28 | $em->persist($ship); 29 | $em->persist($faction); 30 | 31 | try { 32 | $em->flush(); 33 | } catch (\Exception $e) { 34 | throw new UserError(sprintf('Could not save ship with name "%s". Retry later', $shipName)); 35 | } 36 | 37 | return [ 38 | 'ship' => $ship, 39 | 'faction' => $faction, 40 | ]; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/AppBundle/GraphQL/Relay/Resolver/FactionResolver.php: -------------------------------------------------------------------------------- 1 | getFactionByType(Faction::TYPE_REBELS); 18 | 19 | return $rebels; 20 | } 21 | 22 | public function resolveEmpire() 23 | { 24 | $empire = $this->getFactionByType(Faction::TYPE_EMPIRE); 25 | 26 | return $empire; 27 | } 28 | 29 | public function resolveFake() 30 | { 31 | $fake = $this->getFactionByType(Faction::TYPE_FAKE); 32 | 33 | return $fake; 34 | } 35 | 36 | public function resolveShips(Faction $faction, $args) 37 | { 38 | //The old way 39 | //$ships = $faction->getShips()->toArray(); 40 | //$connection = ConnectionBuilder::connectionFromArray($ships, $args); 41 | //$connection->sliceSize = count($connection->edges); 42 | //return $connection; 43 | 44 | /** @var ShipRepository $repository */ 45 | $repository = $this->container 46 | ->get('doctrine.orm.default_entity_manager') 47 | ->getRepository('AppBundle:Ship'); 48 | 49 | $arrayLength = $repository->countAllByFactionId($faction->getId()); 50 | 51 | //-------------------------------------------------------------------------------------------------------------- 52 | //todo move in vendor ? 53 | $beforeOffset = ConnectionBuilder::getOffsetWithDefault($args['before'], $arrayLength); 54 | $afterOffset = ConnectionBuilder::getOffsetWithDefault($args['after'], -1); 55 | 56 | $startOffset = max($afterOffset, -1) + 1; 57 | $endOffset = min($beforeOffset, $arrayLength); 58 | 59 | if (is_numeric($args['first'])) { 60 | $endOffset = min($endOffset, $startOffset + $args['first']); 61 | } 62 | if (is_numeric($args['last'])) { 63 | $startOffset = max($startOffset, $endOffset - $args['last']); 64 | } 65 | $offset = max($startOffset, 0); 66 | $limit = $endOffset - $startOffset; 67 | //-------------------------------------------------------------------------------------------------------------- 68 | 69 | $ships = $repository->retrieveShipsByFactionId($faction->getId(), $offset, $limit); 70 | 71 | $connection = ConnectionBuilder::connectionFromArraySlice( 72 | $ships, 73 | $args, 74 | [ 75 | 'sliceStart' => $offset, 76 | 'arrayLength' => $arrayLength, 77 | ] 78 | ); 79 | $connection->sliceSize = count($ships); 80 | 81 | return $connection; 82 | } 83 | 84 | private function getFactionByType($type) 85 | { 86 | return $this->container->get('doctrine.orm.default_entity_manager') 87 | ->getRepository('AppBundle:Faction')->findOneBy(['type' => $type]); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/AppBundle/GraphQL/Relay/Resolver/NodeResolver.php: -------------------------------------------------------------------------------- 1 | container->get('doctrine.orm.default_entity_manager') 30 | ->find('AppBundle:'.$params['type'], $params['id']); 31 | } 32 | 33 | return; 34 | } 35 | 36 | /** 37 | * @param $object 38 | * 39 | * @return \GraphQL\Type\Definition\Type 40 | */ 41 | public function resolveType($object) 42 | { 43 | $typeResolver = $this->container->get('overblog_graphql.type_resolver'); 44 | 45 | return $object instanceof Ship ? $typeResolver->resolve('Ship') : $typeResolver->resolve('Faction'); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/AppBundle/GraphQL/Resolver/CharacterResolver.php: -------------------------------------------------------------------------------- 1 | container->get('overblog_graphql.type_resolver'); 20 | 21 | return $typeResolver->resolve($character->getType()); 22 | } 23 | 24 | public function resolveHero($args) 25 | { 26 | return $this->getHero($args['episode']); 27 | } 28 | 29 | public function resolveHuman($args) 30 | { 31 | return $this->resolveCharacter($args['id'], Character::TYPE_HUMAN); 32 | } 33 | 34 | public function resolveDroid($args) 35 | { 36 | return $this->resolveCharacter($args['id'], Character::TYPE_DROID); 37 | } 38 | 39 | private function resolveCharacter($id, $type) 40 | { 41 | $character = $this->getCharacter($id); 42 | if (null === $character) { 43 | return; 44 | } 45 | 46 | return $type === $character->getType() ? $character : null; 47 | } 48 | 49 | private function getHero($episode) 50 | { 51 | if ($episode === 5) { 52 | // Luke is the hero of Episode V. 53 | $id = 1000; 54 | } else { 55 | // Artoo is the hero otherwise. 56 | $id = 2001; 57 | } 58 | 59 | return $this->getCharacter($id); 60 | } 61 | 62 | /** 63 | * @param $id 64 | * 65 | * @return Character|null 66 | */ 67 | private function getCharacter($id) 68 | { 69 | return $this->container->get('doctrine.orm.default_entity_manager') 70 | ->find('AppBundle:Character', (int) $id); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/AppBundle/Resources/config/doctrine/Character.orm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/AppBundle/Resources/config/doctrine/Faction.orm.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/AppBundle/Resources/config/doctrine/Ship.orm.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/AppBundle/Resources/config/graphql-relay.yml: -------------------------------------------------------------------------------- 1 | services: 2 | app.graph.resolver.node: 3 | class: AppBundle\GraphQL\Relay\Resolver\NodeResolver 4 | tags: 5 | - { name: overblog_graphql.resolver, alias: "node", method: "resolveNode" } 6 | - { name: overblog_graphql.resolver, alias: "node_type", method: "resolveType" } 7 | 8 | app.graph.resolver.faction: 9 | class: AppBundle\GraphQL\Relay\Resolver\FactionResolver 10 | tags: 11 | - { name: overblog_graphql.resolver, alias: "faction_rebels", method: "resolveRebels" } 12 | - { name: overblog_graphql.resolver, alias: "faction_empire", method: "resolveEmpire" } 13 | - { name: overblog_graphql.resolver, alias: "faction_fake", method: "resolveFake" } 14 | - { name: overblog_graphql.resolver, alias: "faction_ships", method: "resolveShips" } 15 | 16 | app.graph.mutation.ship: 17 | class: AppBundle\GraphQL\Relay\Mutation\ShipMutation 18 | tags: 19 | - { name: overblog_graphql.mutation, alias: "create_ship", method: "createShip" } 20 | -------------------------------------------------------------------------------- /src/AppBundle/Resources/config/graphql.yml: -------------------------------------------------------------------------------- 1 | services: 2 | app.graph.resolver.character: 3 | class: AppBundle\GraphQL\Resolver\CharacterResolver 4 | tags: 5 | - { name: overblog_graphql.resolver, alias: "character_type", method: "resolveType" } 6 | - { name: overblog_graphql.resolver, alias: "character_hero", method: "resolveHero" } 7 | - { name: overblog_graphql.resolver, alias: "character_human", method: "resolveHuman" } 8 | - { name: overblog_graphql.resolver, alias: "character_droid", method: "resolveDroid" } 9 | -------------------------------------------------------------------------------- /src/AppBundle/Resources/config/graphql/Character.types.yml: -------------------------------------------------------------------------------- 1 | # Characters in the Star Wars trilogy are either humans or droids. 2 | # 3 | # This implements the following type system shorthand: 4 | # interface Character { 5 | # id: String! 6 | # name: String 7 | # friends: [Character] 8 | # appearsIn: [Episode] 9 | # } 10 | Character: 11 | type: interface 12 | config: 13 | description: "A character in the Star Wars Trilogy" 14 | fields: 15 | id: 16 | type: "String!" 17 | description: "The id of the character." 18 | name: 19 | type: "String" 20 | description: "The name of the character." 21 | friends: 22 | type: "[Character]" 23 | description: "The friends of the character." 24 | appearsIn: 25 | type: "[Episode]" 26 | description: "Which movies they appear in." 27 | # used expression language to defined resolver (tagged services) 28 | resolveType: "@=resolver('character_type', [value])" -------------------------------------------------------------------------------- /src/AppBundle/Resources/config/graphql/Droid.types.yml: -------------------------------------------------------------------------------- 1 | # The other type of character in Star Wars is a droid. 2 | # 3 | # This implements the following type system shorthand: 4 | # type Droid : Character { 5 | # id: String! 6 | # name: String 7 | # friends: [Character] 8 | # appearsIn: [Episode] 9 | # primaryFunction: String 10 | # } 11 | Droid: 12 | type: object 13 | config: 14 | description: "A mechanical creature in the Star Wars universe." 15 | fields: 16 | id: 17 | type: "String!" 18 | description: "The id of the droid." 19 | name: 20 | type: "String" 21 | description: "The name of the droid." 22 | friends: 23 | type: "[Character]" 24 | description: "The friends of the droid, or an empty list if they have none." 25 | appearsIn: 26 | type: "[Episode]" 27 | description: "Which movies they appear in." 28 | primaryFunction: 29 | type: "String" 30 | description: "The primary function of the droid." 31 | interfaces: [Character] 32 | -------------------------------------------------------------------------------- /src/AppBundle/Resources/config/graphql/Episode.types.yml: -------------------------------------------------------------------------------- 1 | # The original trilogy consists of three movies. 2 | # This implements the following type system shorthand: 3 | # enum Episode { NEWHOPE, EMPIRE, JEDI } 4 | Episode: 5 | type: enum 6 | config: 7 | description: "One of the films in the Star Wars Trilogy" 8 | values: 9 | NEWHOPE: 10 | value: 4 11 | description: "Released in 1977." 12 | EMPIRE: 13 | value: 5 14 | description: "Released in 1980." 15 | JEDI: 16 | value: 6 17 | description: "Released in 1983." -------------------------------------------------------------------------------- /src/AppBundle/Resources/config/graphql/Human.types.yml: -------------------------------------------------------------------------------- 1 | # We define our human type, which implements the character interface. 2 | # 3 | # This implements the following type system shorthand: 4 | # type Human : Character { 5 | # id: String! 6 | # name: String 7 | # friends: [Character] 8 | # appearsIn: [Episode] 9 | # } 10 | Human: 11 | type: object 12 | config: 13 | description: "A humanoid creature in the Star Wars universe." 14 | fields: 15 | id: 16 | type: "String!" 17 | description: "The id of the character." 18 | name: 19 | type: "String" 20 | description: "The name of the character." 21 | friends: 22 | type: "[Character]" 23 | description: "The friends of the character." 24 | appearsIn: 25 | type: "[Episode]" 26 | description: "Which movies they appear in." 27 | homePlanet: 28 | type: "String" 29 | description: "The home planet of the human, or null if unknown." 30 | interfaces: [Character] 31 | -------------------------------------------------------------------------------- /src/AppBundle/Resources/config/graphql/Mutation.types.yml: -------------------------------------------------------------------------------- 1 | Mutation: 2 | type: object 3 | config: 4 | fields: 5 | introduceShip: 6 | builder: Relay::Mutation 7 | builderConfig: 8 | inputType: IntroduceShipInput 9 | payloadType: IntroduceShipPayload 10 | mutateAndGetPayload: "@=mutation('create_ship', [value['shipName'], value['factionId']])" 11 | -------------------------------------------------------------------------------- /src/AppBundle/Resources/config/graphql/Query.types.yml: -------------------------------------------------------------------------------- 1 | # This is the type that will be the root of our query, and the 2 | # entry point into our schema. It gives us the ability to fetch 3 | # objects by their IDs, as well as to fetch the undisputed hero 4 | # of the Star Wars trilogy, R2-D2, directly. 5 | # This is the type that will be the root of our query, and the 6 | # entry point into our schema. 7 | # 8 | # This implements the following type system shorthand: 9 | # type Query { 10 | # hero(episode: Episode): Character 11 | # human(id: String!): Human 12 | # droid(id: String!): Droid 13 | # rebels: Faction 14 | # empire: Faction 15 | # node(id: String!): Node 16 | # } 17 | # 18 | Query: 19 | type: object 20 | config: 21 | description: "A humanoid creature in the Star Wars universe or a faction in the Star Wars saga." 22 | fields: 23 | hero: 24 | type: "Character" 25 | args: 26 | episode: 27 | description: "If omitted, returns the hero of the whole saga. If provided, returns the hero of that particular episode." 28 | type: "Episode" 29 | resolve: "@=resolver('character_hero', [args])" 30 | human: 31 | type: "Human" 32 | args: 33 | id: 34 | description: "id of the human" 35 | type: "String!" 36 | resolve: "@=resolver('character_human', [args])" 37 | droid: 38 | type: "Droid" 39 | args: 40 | id: 41 | description: "id of the droid" 42 | type: "String!" 43 | resolve: "@=resolver('character_droid', [args])" 44 | rebels: 45 | type: "Faction" 46 | resolve: "@=resolver('faction_rebels', [])" 47 | empire: 48 | type: "Faction" 49 | resolve: "@=resolver('faction_empire', [])" 50 | fake: 51 | type: "Faction" 52 | resolve: "@=resolver('faction_fake', [])" 53 | node: 54 | builder: Relay::Node 55 | builderConfig: 56 | nodeInterfaceType: Node 57 | idFetcher: '@=resolver("node", [value])' 58 | -------------------------------------------------------------------------------- /src/AppBundle/Resources/config/graphql/relay/Faction.types.yml: -------------------------------------------------------------------------------- 1 | # We define our faction type, which implements the node interface. 2 | # 3 | # This implements the following type system shorthand: 4 | # type Faction : Node { 5 | # id: String! 6 | # name: String 7 | # ships: ShipConnection 8 | # } 9 | Faction: 10 | type: object 11 | config: 12 | description: "A faction in the Star Wars saga" 13 | fields: 14 | id: { builder: Relay::GlobalId } 15 | name: 16 | type: "String" 17 | description: "The name of the faction." 18 | ships: 19 | type: "ShipConnection" 20 | description: "The ships used by the faction." 21 | argsBuilder: Relay::Connection 22 | resolve: '@=resolver("faction_ships", [value, args])' 23 | primaryFunction: 24 | type: "String" 25 | description: "The primary function of the droid." 26 | interfaces: [Node] 27 | -------------------------------------------------------------------------------- /src/AppBundle/Resources/config/graphql/relay/IntroduceShipMutation.types.yml: -------------------------------------------------------------------------------- 1 | # input IntroduceShipInput { 2 | # clientMutationId: string! 3 | # shipName: string! 4 | # factionId: ID! 5 | # } 6 | # 7 | # input IntroduceShipPayload { 8 | # clientMutationId: string! 9 | # ship: Ship 10 | # faction: Faction 11 | # } 12 | IntroduceShipInput: 13 | type: relay-mutation-input 14 | config: 15 | fields: 16 | shipName: 17 | type: "String!" 18 | factionId: 19 | type: "String!" 20 | 21 | IntroduceShipPayload: 22 | type: relay-mutation-payload 23 | config: 24 | fields: 25 | ship: 26 | type: "Ship" 27 | faction: 28 | type: "Faction" 29 | -------------------------------------------------------------------------------- /src/AppBundle/Resources/config/graphql/relay/Node.types.yml: -------------------------------------------------------------------------------- 1 | # interface Node { 2 | # id: ID! 3 | # } 4 | Node: 5 | type: relay-node 6 | config: 7 | resolveType: '@=resolver("node_type", [value])' 8 | -------------------------------------------------------------------------------- /src/AppBundle/Resources/config/graphql/relay/Ship.types.yml: -------------------------------------------------------------------------------- 1 | # We define our basic ship type. 2 | # 3 | # This implements the following type system shorthand: 4 | # type Ship : Node { 5 | # id: String! 6 | # name: String 7 | # } 8 | Ship: 9 | type: object 10 | config: 11 | description: "A ship in the Star Wars saga" 12 | fields: 13 | id: { builder: Relay::GlobalId } 14 | name: 15 | type: "String" 16 | description: "The name of the ship." 17 | interfaces: [Node] 18 | -------------------------------------------------------------------------------- /src/AppBundle/Resources/config/graphql/relay/ShipConnection.types.yml: -------------------------------------------------------------------------------- 1 | # We define a connection between a faction and its ships. 2 | # 3 | # connectionType implements the following type system shorthand: 4 | # type ShipConnection { 5 | # edges: [ShipEdge] 6 | # pageInfo: PageInfo! 7 | # } 8 | # 9 | # connectionType has an edges field - a list of edgeTypes that implement the 10 | # following type system shorthand: 11 | # type ShipEdge { 12 | # cursor: String! 13 | # node: Ship 14 | # } 15 | ShipConnection: 16 | type: relay-connection 17 | config: 18 | nodeType: Ship 19 | connectionFields: 20 | sliceSize: 21 | type: "Int!" 22 | -------------------------------------------------------------------------------- /tests/AppBundle/Functional/Relay/StarWarsConnectionTest.php: -------------------------------------------------------------------------------- 1 | assertQuery($query, $jsonExpected); 46 | } 47 | 48 | public function testFetchesTheFirstTwoShipsOfTheRebelsWithACursor() 49 | { 50 | $query = <<assertQuery($query, $jsonExpected); 93 | } 94 | 95 | public function testFetchesTheNextThreeShipsOfTheRebelsWithACursor() 96 | { 97 | $query = <<assertQuery($query, $jsonExpected); 146 | } 147 | 148 | public function testFetchesNoShipsOfTheRebelsAtTheEndOfConnection() 149 | { 150 | $query = <<assertQuery($query, $jsonExpected); 180 | } 181 | 182 | public function testIdentifiesTheEndOfTheList() 183 | { 184 | $query = <<assertQuery($query, $jsonExpected); 262 | } 263 | 264 | public function testFetchesShipsWithLastBeforeAndAfter() 265 | { 266 | $query = <<assertQuery($query, $jsonExpected); 317 | } 318 | 319 | public function testFetchesShipsWithLastAfter() 320 | { 321 | $query = <<assertQuery($query, $jsonExpected); 378 | } 379 | } 380 | -------------------------------------------------------------------------------- /tests/AppBundle/Functional/Relay/StarWarsMutationTest.php: -------------------------------------------------------------------------------- 1 | assertQuery($query, $jsonExpected, $jsonVariables); 53 | $this->resetDatabase(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /tests/AppBundle/Functional/Relay/StarWarsObjectIdentificationTest.php: -------------------------------------------------------------------------------- 1 | assertQuery($query, $jsonExpected); 32 | } 33 | 34 | public function testRefetchesTheRebels() 35 | { 36 | $query = <<assertQuery($query, $jsonExpected); 60 | } 61 | 62 | public function testFetchesTheIdAndNameOfTheEmpire() 63 | { 64 | $query = <<assertQuery($query, $jsonExpected); 85 | } 86 | 87 | public function testRefetchesTheXWing() 88 | { 89 | $query = <<assertQuery($query, $jsonExpected); 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /tests/AppBundle/Functional/StarWarsQueryTest.php: -------------------------------------------------------------------------------- 1 | assertQuery($query, $jsonExpected); 30 | } 31 | 32 | public function testAllowsUsToQueryForTheIdAndFriendsOfR2D2() 33 | { 34 | $query = <<<'EOF' 35 | query HeroNameAndFriendsQuery { 36 | hero { 37 | id 38 | name 39 | friends { 40 | name 41 | } 42 | } 43 | } 44 | EOF; 45 | 46 | $jsonExpected = <<assertQuery($query, $jsonExpected); 69 | } 70 | 71 | public function testAllowsUsToQueryForTheFriendsOfFriendsOfR2D2() 72 | { 73 | $query = <<<'EOF' 74 | query NestedQuery { 75 | hero { 76 | name 77 | friends { 78 | name 79 | appearsIn 80 | friends { 81 | name 82 | } 83 | } 84 | } 85 | } 86 | EOF; 87 | 88 | $jsonExpected = <<assertQuery($query, $jsonExpected); 164 | } 165 | 166 | public function testAllowsUsToQueryForLukeSkywalkerDirectlyUsingHisId() 167 | { 168 | $query = <<<'EOF' 169 | query FetchLukeQuery { 170 | human(id: "1000") { 171 | name 172 | } 173 | } 174 | EOF; 175 | 176 | $jsonExpected = <<assertQuery($query, $jsonExpected); 187 | } 188 | 189 | public function testAllowsUsToCreateAGenericQueryThenUseItToFetchLukeSkywalkerUsingHisId() 190 | { 191 | $query = <<<'EOF' 192 | query FetchSomeIDQuery($someId: String!) { 193 | human(id: $someId) { 194 | name 195 | } 196 | } 197 | EOF; 198 | 199 | $jsonExpected = <<assertQuery($query, $jsonExpected, $jsonVariables); 215 | } 216 | 217 | public function testAllowsUsToCreateAGenericQueryThenUseItToFetchHanSoloUsingHisId() 218 | { 219 | $query = <<<'EOF' 220 | query FetchSomeIDQuery($someId: String!) { 221 | human(id: $someId) { 222 | name 223 | } 224 | } 225 | EOF; 226 | 227 | $jsonExpected = <<assertQuery($query, $jsonExpected, $jsonVariables); 243 | } 244 | 245 | public function testAllowsUsToCreateAGenericQueryThenPassAnInvalidIdToGetNullBack() 246 | { 247 | $query = <<<'EOF' 248 | query humanQuery($id: String!) { 249 | human(id: $id) { 250 | name 251 | } 252 | } 253 | EOF; 254 | 255 | $jsonExpected = <<assertQuery($query, $jsonExpected, $jsonVariables); 269 | } 270 | 271 | public function testAllowsUsToQueryForLukeChangingHisKeyWithAnAlias() 272 | { 273 | $query = <<<'EOF' 274 | query FetchLukeAliased { 275 | luke: human(id: "1000") { 276 | name 277 | } 278 | } 279 | EOF; 280 | 281 | $jsonExpected = <<assertQuery($query, $jsonExpected); 292 | } 293 | 294 | public function testAllowsUsToQueryForBothLukeAndLeiaUsingTwoRootFieldsAndAnAlias() 295 | { 296 | $query = <<<'EOF' 297 | query FetchLukeAndLeiaAliased { 298 | luke: human(id: "1000") { 299 | name 300 | } 301 | leia: human(id: "1003") { 302 | name 303 | } 304 | } 305 | EOF; 306 | 307 | $jsonExpected = <<assertQuery($query, $jsonExpected); 321 | } 322 | 323 | public function testAllowsUsToQueryUsingDuplicatedContent() 324 | { 325 | $query = <<<'EOF' 326 | query DuplicateFields { 327 | luke: human(id: "1000") { 328 | name 329 | homePlanet 330 | } 331 | leia: human(id: "1003") { 332 | name 333 | homePlanet 334 | } 335 | } 336 | EOF; 337 | 338 | $jsonExpected = <<assertQuery($query, $jsonExpected); 354 | } 355 | 356 | public function testAllowsUsToUseAFragmentToAvoidDuplicatingContent() 357 | { 358 | $query = <<<'EOF' 359 | query UseFragment { 360 | luke: human(id: "1000") { 361 | ...HumanFragment 362 | } 363 | leia: human(id: "1003") { 364 | ...HumanFragment 365 | } 366 | } 367 | 368 | fragment HumanFragment on Human { 369 | name 370 | homePlanet 371 | } 372 | EOF; 373 | 374 | $jsonExpected = <<assertQuery($query, $jsonExpected); 390 | } 391 | 392 | public function testAllowsUsToVerifyThatR2D2IsADroid() 393 | { 394 | $query = <<<'EOF' 395 | query CheckTypeOfR2 { 396 | hero { 397 | __typename 398 | name 399 | } 400 | } 401 | EOF; 402 | 403 | $jsonExpected = <<assertQuery($query, $jsonExpected); 415 | } 416 | 417 | public function testAllowsUsToVerifyThatLukeIsAHuman() 418 | { 419 | $query = <<<'EOF' 420 | query CheckTypeOfLuke { 421 | hero(episode: EMPIRE) { 422 | __typename 423 | name 424 | } 425 | } 426 | EOF; 427 | 428 | $jsonExpected = <<assertQuery($query, $jsonExpected); 440 | } 441 | } 442 | -------------------------------------------------------------------------------- /tests/AppBundle/Functional/WebTestCase.php: -------------------------------------------------------------------------------- 1 | resetDatabase(); 18 | self::$dbLoaded = true; 19 | } 20 | 21 | protected function resetDatabase() 22 | { 23 | $em = $this->getContainer()->get('doctrine')->getManager(); 24 | if (!isset($metadatas)) { 25 | $metadatas = $em->getMetadataFactory()->getAllMetadata(); 26 | } 27 | $schemaTool = new SchemaTool($em); 28 | $schemaTool->dropDatabase(); 29 | if (!empty($metadatas)) { 30 | $schemaTool->createSchema($metadatas); 31 | } 32 | $this->postFixtureSetup(); 33 | 34 | $this->loadFixtures([ 35 | 'AppBundle\DataFixtures\ORM\LoadCharacterData', 36 | 'AppBundle\DataFixtures\ORM\LoadShipAndFactionData' 37 | ]); 38 | } 39 | 40 | protected function assertQuery($query, $jsonExpected, $jsonVariables = '{}') 41 | { 42 | $client = static::makeClient(); 43 | $path = $this->getUrl('overblog_graphql_endpoint'); 44 | 45 | $client->request( 46 | 'GET', $path, ['query' => $query, 'variables' => $jsonVariables], [], ['CONTENT_TYPE' => 'application/graphql'] 47 | ); 48 | $result = $client->getResponse()->getContent(); 49 | $this->assertStatusCode(200, $client); 50 | $this->assertEquals(json_decode($jsonExpected, true), json_decode($result, true), $result); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /var/SymfonyRequirements.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | /* 13 | * Users of PHP 5.2 should be able to run the requirements checks. 14 | * This is why the file and all classes must be compatible with PHP 5.2+ 15 | * (e.g. not using namespaces and closures). 16 | * 17 | * ************** CAUTION ************** 18 | * 19 | * DO NOT EDIT THIS FILE as it will be overridden by Composer as part of 20 | * the installation/update process. The original file resides in the 21 | * SensioDistributionBundle. 22 | * 23 | * ************** CAUTION ************** 24 | */ 25 | 26 | /** 27 | * Represents a single PHP requirement, e.g. an installed extension. 28 | * It can be a mandatory requirement or an optional recommendation. 29 | * There is a special subclass, named PhpIniRequirement, to check a php.ini configuration. 30 | * 31 | * @author Tobias Schultze 32 | */ 33 | class Requirement 34 | { 35 | private $fulfilled; 36 | private $testMessage; 37 | private $helpText; 38 | private $helpHtml; 39 | private $optional; 40 | 41 | /** 42 | * Constructor that initializes the requirement. 43 | * 44 | * @param bool $fulfilled Whether the requirement is fulfilled 45 | * @param string $testMessage The message for testing the requirement 46 | * @param string $helpHtml The help text formatted in HTML for resolving the problem 47 | * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) 48 | * @param bool $optional Whether this is only an optional recommendation not a mandatory requirement 49 | */ 50 | public function __construct($fulfilled, $testMessage, $helpHtml, $helpText = null, $optional = false) 51 | { 52 | $this->fulfilled = (bool) $fulfilled; 53 | $this->testMessage = (string) $testMessage; 54 | $this->helpHtml = (string) $helpHtml; 55 | $this->helpText = null === $helpText ? strip_tags($this->helpHtml) : (string) $helpText; 56 | $this->optional = (bool) $optional; 57 | } 58 | 59 | /** 60 | * Returns whether the requirement is fulfilled. 61 | * 62 | * @return bool true if fulfilled, otherwise false 63 | */ 64 | public function isFulfilled() 65 | { 66 | return $this->fulfilled; 67 | } 68 | 69 | /** 70 | * Returns the message for testing the requirement. 71 | * 72 | * @return string The test message 73 | */ 74 | public function getTestMessage() 75 | { 76 | return $this->testMessage; 77 | } 78 | 79 | /** 80 | * Returns the help text for resolving the problem. 81 | * 82 | * @return string The help text 83 | */ 84 | public function getHelpText() 85 | { 86 | return $this->helpText; 87 | } 88 | 89 | /** 90 | * Returns the help text formatted in HTML. 91 | * 92 | * @return string The HTML help 93 | */ 94 | public function getHelpHtml() 95 | { 96 | return $this->helpHtml; 97 | } 98 | 99 | /** 100 | * Returns whether this is only an optional recommendation and not a mandatory requirement. 101 | * 102 | * @return bool true if optional, false if mandatory 103 | */ 104 | public function isOptional() 105 | { 106 | return $this->optional; 107 | } 108 | } 109 | 110 | /** 111 | * Represents a PHP requirement in form of a php.ini configuration. 112 | * 113 | * @author Tobias Schultze 114 | */ 115 | class PhpIniRequirement extends Requirement 116 | { 117 | /** 118 | * Constructor that initializes the requirement. 119 | * 120 | * @param string $cfgName The configuration name used for ini_get() 121 | * @param bool|callback $evaluation Either a boolean indicating whether the configuration should evaluate to true or false, 122 | * or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement 123 | * @param bool $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false. 124 | * This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin. 125 | * Example: You require a config to be true but PHP later removes this config and defaults it to true internally. 126 | * @param string|null $testMessage The message for testing the requirement (when null and $evaluation is a boolean a default message is derived) 127 | * @param string|null $helpHtml The help text formatted in HTML for resolving the problem (when null and $evaluation is a boolean a default help is derived) 128 | * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) 129 | * @param bool $optional Whether this is only an optional recommendation not a mandatory requirement 130 | */ 131 | public function __construct($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null, $optional = false) 132 | { 133 | $cfgValue = ini_get($cfgName); 134 | 135 | if (is_callable($evaluation)) { 136 | if (null === $testMessage || null === $helpHtml) { 137 | throw new InvalidArgumentException('You must provide the parameters testMessage and helpHtml for a callback evaluation.'); 138 | } 139 | 140 | $fulfilled = call_user_func($evaluation, $cfgValue); 141 | } else { 142 | if (null === $testMessage) { 143 | $testMessage = sprintf('%s %s be %s in php.ini', 144 | $cfgName, 145 | $optional ? 'should' : 'must', 146 | $evaluation ? 'enabled' : 'disabled' 147 | ); 148 | } 149 | 150 | if (null === $helpHtml) { 151 | $helpHtml = sprintf('Set %s to %s in php.ini*.', 152 | $cfgName, 153 | $evaluation ? 'on' : 'off' 154 | ); 155 | } 156 | 157 | $fulfilled = $evaluation == $cfgValue; 158 | } 159 | 160 | parent::__construct($fulfilled || ($approveCfgAbsence && false === $cfgValue), $testMessage, $helpHtml, $helpText, $optional); 161 | } 162 | } 163 | 164 | /** 165 | * A RequirementCollection represents a set of Requirement instances. 166 | * 167 | * @author Tobias Schultze 168 | */ 169 | class RequirementCollection implements IteratorAggregate 170 | { 171 | /** 172 | * @var Requirement[] 173 | */ 174 | private $requirements = array(); 175 | 176 | /** 177 | * Gets the current RequirementCollection as an Iterator. 178 | * 179 | * @return Traversable A Traversable interface 180 | */ 181 | public function getIterator() 182 | { 183 | return new ArrayIterator($this->requirements); 184 | } 185 | 186 | /** 187 | * Adds a Requirement. 188 | * 189 | * @param Requirement $requirement A Requirement instance 190 | */ 191 | public function add(Requirement $requirement) 192 | { 193 | $this->requirements[] = $requirement; 194 | } 195 | 196 | /** 197 | * Adds a mandatory requirement. 198 | * 199 | * @param bool $fulfilled Whether the requirement is fulfilled 200 | * @param string $testMessage The message for testing the requirement 201 | * @param string $helpHtml The help text formatted in HTML for resolving the problem 202 | * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) 203 | */ 204 | public function addRequirement($fulfilled, $testMessage, $helpHtml, $helpText = null) 205 | { 206 | $this->add(new Requirement($fulfilled, $testMessage, $helpHtml, $helpText, false)); 207 | } 208 | 209 | /** 210 | * Adds an optional recommendation. 211 | * 212 | * @param bool $fulfilled Whether the recommendation is fulfilled 213 | * @param string $testMessage The message for testing the recommendation 214 | * @param string $helpHtml The help text formatted in HTML for resolving the problem 215 | * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) 216 | */ 217 | public function addRecommendation($fulfilled, $testMessage, $helpHtml, $helpText = null) 218 | { 219 | $this->add(new Requirement($fulfilled, $testMessage, $helpHtml, $helpText, true)); 220 | } 221 | 222 | /** 223 | * Adds a mandatory requirement in form of a php.ini configuration. 224 | * 225 | * @param string $cfgName The configuration name used for ini_get() 226 | * @param bool|callback $evaluation Either a boolean indicating whether the configuration should evaluate to true or false, 227 | * or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement 228 | * @param bool $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false. 229 | * This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin. 230 | * Example: You require a config to be true but PHP later removes this config and defaults it to true internally. 231 | * @param string $testMessage The message for testing the requirement (when null and $evaluation is a boolean a default message is derived) 232 | * @param string $helpHtml The help text formatted in HTML for resolving the problem (when null and $evaluation is a boolean a default help is derived) 233 | * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) 234 | */ 235 | public function addPhpIniRequirement($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null) 236 | { 237 | $this->add(new PhpIniRequirement($cfgName, $evaluation, $approveCfgAbsence, $testMessage, $helpHtml, $helpText, false)); 238 | } 239 | 240 | /** 241 | * Adds an optional recommendation in form of a php.ini configuration. 242 | * 243 | * @param string $cfgName The configuration name used for ini_get() 244 | * @param bool|callback $evaluation Either a boolean indicating whether the configuration should evaluate to true or false, 245 | * or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement 246 | * @param bool $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false. 247 | * This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin. 248 | * Example: You require a config to be true but PHP later removes this config and defaults it to true internally. 249 | * @param string $testMessage The message for testing the requirement (when null and $evaluation is a boolean a default message is derived) 250 | * @param string $helpHtml The help text formatted in HTML for resolving the problem (when null and $evaluation is a boolean a default help is derived) 251 | * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) 252 | */ 253 | public function addPhpIniRecommendation($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null) 254 | { 255 | $this->add(new PhpIniRequirement($cfgName, $evaluation, $approveCfgAbsence, $testMessage, $helpHtml, $helpText, true)); 256 | } 257 | 258 | /** 259 | * Adds a requirement collection to the current set of requirements. 260 | * 261 | * @param RequirementCollection $collection A RequirementCollection instance 262 | */ 263 | public function addCollection(RequirementCollection $collection) 264 | { 265 | $this->requirements = array_merge($this->requirements, $collection->all()); 266 | } 267 | 268 | /** 269 | * Returns both requirements and recommendations. 270 | * 271 | * @return Requirement[] 272 | */ 273 | public function all() 274 | { 275 | return $this->requirements; 276 | } 277 | 278 | /** 279 | * Returns all mandatory requirements. 280 | * 281 | * @return Requirement[] 282 | */ 283 | public function getRequirements() 284 | { 285 | $array = array(); 286 | foreach ($this->requirements as $req) { 287 | if (!$req->isOptional()) { 288 | $array[] = $req; 289 | } 290 | } 291 | 292 | return $array; 293 | } 294 | 295 | /** 296 | * Returns the mandatory requirements that were not met. 297 | * 298 | * @return Requirement[] 299 | */ 300 | public function getFailedRequirements() 301 | { 302 | $array = array(); 303 | foreach ($this->requirements as $req) { 304 | if (!$req->isFulfilled() && !$req->isOptional()) { 305 | $array[] = $req; 306 | } 307 | } 308 | 309 | return $array; 310 | } 311 | 312 | /** 313 | * Returns all optional recommendations. 314 | * 315 | * @return Requirement[] 316 | */ 317 | public function getRecommendations() 318 | { 319 | $array = array(); 320 | foreach ($this->requirements as $req) { 321 | if ($req->isOptional()) { 322 | $array[] = $req; 323 | } 324 | } 325 | 326 | return $array; 327 | } 328 | 329 | /** 330 | * Returns the recommendations that were not met. 331 | * 332 | * @return Requirement[] 333 | */ 334 | public function getFailedRecommendations() 335 | { 336 | $array = array(); 337 | foreach ($this->requirements as $req) { 338 | if (!$req->isFulfilled() && $req->isOptional()) { 339 | $array[] = $req; 340 | } 341 | } 342 | 343 | return $array; 344 | } 345 | 346 | /** 347 | * Returns whether a php.ini configuration is not correct. 348 | * 349 | * @return bool php.ini configuration problem? 350 | */ 351 | public function hasPhpIniConfigIssue() 352 | { 353 | foreach ($this->requirements as $req) { 354 | if (!$req->isFulfilled() && $req instanceof PhpIniRequirement) { 355 | return true; 356 | } 357 | } 358 | 359 | return false; 360 | } 361 | 362 | /** 363 | * Returns the PHP configuration file (php.ini) path. 364 | * 365 | * @return string|false php.ini file path 366 | */ 367 | public function getPhpIniConfigPath() 368 | { 369 | return get_cfg_var('cfg_file_path'); 370 | } 371 | } 372 | 373 | /** 374 | * This class specifies all requirements and optional recommendations that 375 | * are necessary to run the Symfony Standard Edition. 376 | * 377 | * @author Tobias Schultze 378 | * @author Fabien Potencier 379 | */ 380 | class SymfonyRequirements extends RequirementCollection 381 | { 382 | const LEGACY_REQUIRED_PHP_VERSION = '5.3.3'; 383 | const REQUIRED_PHP_VERSION = '5.5.9'; 384 | 385 | /** 386 | * Constructor that initializes the requirements. 387 | */ 388 | public function __construct() 389 | { 390 | /* mandatory requirements follow */ 391 | 392 | $installedPhpVersion = phpversion(); 393 | $requiredPhpVersion = $this->getPhpRequiredVersion(); 394 | 395 | $this->addRecommendation( 396 | $requiredPhpVersion, 397 | 'Vendors should be installed in order to check all requirements.', 398 | 'Run the composer install command.', 399 | 'Run the "composer install" command.' 400 | ); 401 | 402 | if (false !== $requiredPhpVersion) { 403 | $this->addRequirement( 404 | version_compare($installedPhpVersion, $requiredPhpVersion, '>='), 405 | sprintf('PHP version must be at least %s (%s installed)', $requiredPhpVersion, $installedPhpVersion), 406 | sprintf('You are running PHP version "%s", but Symfony needs at least PHP "%s" to run. 407 | Before using Symfony, upgrade your PHP installation, preferably to the latest version.', 408 | $installedPhpVersion, $requiredPhpVersion), 409 | sprintf('Install PHP %s or newer (installed version is %s)', $requiredPhpVersion, $installedPhpVersion) 410 | ); 411 | } 412 | 413 | $this->addRequirement( 414 | version_compare($installedPhpVersion, '5.3.16', '!='), 415 | 'PHP version must not be 5.3.16 as Symfony won\'t work properly with it', 416 | 'Install PHP 5.3.17 or newer (or downgrade to an earlier PHP version)' 417 | ); 418 | 419 | $this->addRequirement( 420 | is_dir(__DIR__.'/../vendor/composer'), 421 | 'Vendor libraries must be installed', 422 | 'Vendor libraries are missing. Install composer following instructions from http://getcomposer.org/. '. 423 | 'Then run "php composer.phar install" to install them.' 424 | ); 425 | 426 | $cacheDir = is_dir(__DIR__.'/../var/cache') ? __DIR__.'/../var/cache' : __DIR__.'/cache'; 427 | 428 | $this->addRequirement( 429 | is_writable($cacheDir), 430 | 'app/cache/ or var/cache/ directory must be writable', 431 | 'Change the permissions of either "app/cache/" or "var/cache/" directory so that the web server can write into it.' 432 | ); 433 | 434 | $logsDir = is_dir(__DIR__.'/../var/logs') ? __DIR__.'/../var/logs' : __DIR__.'/logs'; 435 | 436 | $this->addRequirement( 437 | is_writable($logsDir), 438 | 'app/logs/ or var/logs/ directory must be writable', 439 | 'Change the permissions of either "app/logs/" or "var/logs/" directory so that the web server can write into it.' 440 | ); 441 | 442 | if (version_compare($installedPhpVersion, '7.0.0', '<')) { 443 | $this->addPhpIniRequirement( 444 | 'date.timezone', true, false, 445 | 'date.timezone setting must be set', 446 | 'Set the "date.timezone" setting in php.ini* (like Europe/Paris).' 447 | ); 448 | } 449 | 450 | if (false !== $requiredPhpVersion && version_compare($installedPhpVersion, $requiredPhpVersion, '>=')) { 451 | $timezones = array(); 452 | foreach (DateTimeZone::listAbbreviations() as $abbreviations) { 453 | foreach ($abbreviations as $abbreviation) { 454 | $timezones[$abbreviation['timezone_id']] = true; 455 | } 456 | } 457 | 458 | $this->addRequirement( 459 | isset($timezones[@date_default_timezone_get()]), 460 | sprintf('Configured default timezone "%s" must be supported by your installation of PHP', @date_default_timezone_get()), 461 | 'Your default timezone is not supported by PHP. Check for typos in your php.ini file and have a look at the list of deprecated timezones at http://php.net/manual/en/timezones.others.php.' 462 | ); 463 | } 464 | 465 | $this->addRequirement( 466 | function_exists('iconv'), 467 | 'iconv() must be available', 468 | 'Install and enable the iconv extension.' 469 | ); 470 | 471 | $this->addRequirement( 472 | function_exists('json_encode'), 473 | 'json_encode() must be available', 474 | 'Install and enable the JSON extension.' 475 | ); 476 | 477 | $this->addRequirement( 478 | function_exists('session_start'), 479 | 'session_start() must be available', 480 | 'Install and enable the session extension.' 481 | ); 482 | 483 | $this->addRequirement( 484 | function_exists('ctype_alpha'), 485 | 'ctype_alpha() must be available', 486 | 'Install and enable the ctype extension.' 487 | ); 488 | 489 | $this->addRequirement( 490 | function_exists('token_get_all'), 491 | 'token_get_all() must be available', 492 | 'Install and enable the Tokenizer extension.' 493 | ); 494 | 495 | $this->addRequirement( 496 | function_exists('simplexml_import_dom'), 497 | 'simplexml_import_dom() must be available', 498 | 'Install and enable the SimpleXML extension.' 499 | ); 500 | 501 | if (function_exists('apc_store') && ini_get('apc.enabled')) { 502 | if (version_compare($installedPhpVersion, '5.4.0', '>=')) { 503 | $this->addRequirement( 504 | version_compare(phpversion('apc'), '3.1.13', '>='), 505 | 'APC version must be at least 3.1.13 when using PHP 5.4', 506 | 'Upgrade your APC extension (3.1.13+).' 507 | ); 508 | } else { 509 | $this->addRequirement( 510 | version_compare(phpversion('apc'), '3.0.17', '>='), 511 | 'APC version must be at least 3.0.17', 512 | 'Upgrade your APC extension (3.0.17+).' 513 | ); 514 | } 515 | } 516 | 517 | $this->addPhpIniRequirement('detect_unicode', false); 518 | 519 | if (extension_loaded('suhosin')) { 520 | $this->addPhpIniRequirement( 521 | 'suhosin.executor.include.whitelist', 522 | create_function('$cfgValue', 'return false !== stripos($cfgValue, "phar");'), 523 | false, 524 | 'suhosin.executor.include.whitelist must be configured correctly in php.ini', 525 | 'Add "phar" to suhosin.executor.include.whitelist in php.ini*.' 526 | ); 527 | } 528 | 529 | if (extension_loaded('xdebug')) { 530 | $this->addPhpIniRequirement( 531 | 'xdebug.show_exception_trace', false, true 532 | ); 533 | 534 | $this->addPhpIniRequirement( 535 | 'xdebug.scream', false, true 536 | ); 537 | 538 | $this->addPhpIniRecommendation( 539 | 'xdebug.max_nesting_level', 540 | create_function('$cfgValue', 'return $cfgValue > 100;'), 541 | true, 542 | 'xdebug.max_nesting_level should be above 100 in php.ini', 543 | 'Set "xdebug.max_nesting_level" to e.g. "250" in php.ini* to stop Xdebug\'s infinite recursion protection erroneously throwing a fatal error in your project.' 544 | ); 545 | } 546 | 547 | $pcreVersion = defined('PCRE_VERSION') ? (float) PCRE_VERSION : null; 548 | 549 | $this->addRequirement( 550 | null !== $pcreVersion, 551 | 'PCRE extension must be available', 552 | 'Install the PCRE extension (version 8.0+).' 553 | ); 554 | 555 | if (extension_loaded('mbstring')) { 556 | $this->addPhpIniRequirement( 557 | 'mbstring.func_overload', 558 | create_function('$cfgValue', 'return (int) $cfgValue === 0;'), 559 | true, 560 | 'string functions should not be overloaded', 561 | 'Set "mbstring.func_overload" to 0 in php.ini* to disable function overloading by the mbstring extension.' 562 | ); 563 | } 564 | 565 | /* optional recommendations follow */ 566 | 567 | if (file_exists(__DIR__.'/../vendor/composer')) { 568 | require_once __DIR__.'/../vendor/autoload.php'; 569 | 570 | try { 571 | $r = new ReflectionClass('Sensio\Bundle\DistributionBundle\SensioDistributionBundle'); 572 | 573 | $contents = file_get_contents(dirname($r->getFileName()).'/Resources/skeleton/app/SymfonyRequirements.php'); 574 | } catch (ReflectionException $e) { 575 | $contents = ''; 576 | } 577 | $this->addRecommendation( 578 | file_get_contents(__FILE__) === $contents, 579 | 'Requirements file should be up-to-date', 580 | 'Your requirements file is outdated. Run composer install and re-check your configuration.' 581 | ); 582 | } 583 | 584 | $this->addRecommendation( 585 | version_compare($installedPhpVersion, '5.3.4', '>='), 586 | 'You should use at least PHP 5.3.4 due to PHP bug #52083 in earlier versions', 587 | 'Your project might malfunction randomly due to PHP bug #52083 ("Notice: Trying to get property of non-object"). Install PHP 5.3.4 or newer.' 588 | ); 589 | 590 | $this->addRecommendation( 591 | version_compare($installedPhpVersion, '5.3.8', '>='), 592 | 'When using annotations you should have at least PHP 5.3.8 due to PHP bug #55156', 593 | 'Install PHP 5.3.8 or newer if your project uses annotations.' 594 | ); 595 | 596 | $this->addRecommendation( 597 | version_compare($installedPhpVersion, '5.4.0', '!='), 598 | 'You should not use PHP 5.4.0 due to the PHP bug #61453', 599 | 'Your project might not work properly due to the PHP bug #61453 ("Cannot dump definitions which have method calls"). Install PHP 5.4.1 or newer.' 600 | ); 601 | 602 | $this->addRecommendation( 603 | version_compare($installedPhpVersion, '5.4.11', '>='), 604 | 'When using the logout handler from the Symfony Security Component, you should have at least PHP 5.4.11 due to PHP bug #63379 (as a workaround, you can also set invalidate_session to false in the security logout handler configuration)', 605 | 'Install PHP 5.4.11 or newer if your project uses the logout handler from the Symfony Security Component.' 606 | ); 607 | 608 | $this->addRecommendation( 609 | (version_compare($installedPhpVersion, '5.3.18', '>=') && version_compare($installedPhpVersion, '5.4.0', '<')) 610 | || 611 | version_compare($installedPhpVersion, '5.4.8', '>='), 612 | 'You should use PHP 5.3.18+ or PHP 5.4.8+ to always get nice error messages for fatal errors in the development environment due to PHP bug #61767/#60909', 613 | 'Install PHP 5.3.18+ or PHP 5.4.8+ if you want nice error messages for all fatal errors in the development environment.' 614 | ); 615 | 616 | if (null !== $pcreVersion) { 617 | $this->addRecommendation( 618 | $pcreVersion >= 8.0, 619 | sprintf('PCRE extension should be at least version 8.0 (%s installed)', $pcreVersion), 620 | 'PCRE 8.0+ is preconfigured in PHP since 5.3.2 but you are using an outdated version of it. Symfony probably works anyway but it is recommended to upgrade your PCRE extension.' 621 | ); 622 | } 623 | 624 | $this->addRecommendation( 625 | class_exists('DomDocument'), 626 | 'PHP-DOM and PHP-XML modules should be installed', 627 | 'Install and enable the PHP-DOM and the PHP-XML modules.' 628 | ); 629 | 630 | $this->addRecommendation( 631 | function_exists('mb_strlen'), 632 | 'mb_strlen() should be available', 633 | 'Install and enable the mbstring extension.' 634 | ); 635 | 636 | $this->addRecommendation( 637 | function_exists('utf8_decode'), 638 | 'utf8_decode() should be available', 639 | 'Install and enable the XML extension.' 640 | ); 641 | 642 | $this->addRecommendation( 643 | function_exists('filter_var'), 644 | 'filter_var() should be available', 645 | 'Install and enable the filter extension.' 646 | ); 647 | 648 | if (!defined('PHP_WINDOWS_VERSION_BUILD')) { 649 | $this->addRecommendation( 650 | function_exists('posix_isatty'), 651 | 'posix_isatty() should be available', 652 | 'Install and enable the php_posix extension (used to colorize the CLI output).' 653 | ); 654 | } 655 | 656 | $this->addRecommendation( 657 | extension_loaded('intl'), 658 | 'intl extension should be available', 659 | 'Install and enable the intl extension (used for validators).' 660 | ); 661 | 662 | if (extension_loaded('intl')) { 663 | // in some WAMP server installations, new Collator() returns null 664 | $this->addRecommendation( 665 | null !== new Collator('fr_FR'), 666 | 'intl extension should be correctly configured', 667 | 'The intl extension does not behave properly. This problem is typical on PHP 5.3.X x64 WIN builds.' 668 | ); 669 | 670 | // check for compatible ICU versions (only done when you have the intl extension) 671 | if (defined('INTL_ICU_VERSION')) { 672 | $version = INTL_ICU_VERSION; 673 | } else { 674 | $reflector = new ReflectionExtension('intl'); 675 | 676 | ob_start(); 677 | $reflector->info(); 678 | $output = strip_tags(ob_get_clean()); 679 | 680 | preg_match('/^ICU version +(?:=> )?(.*)$/m', $output, $matches); 681 | $version = $matches[1]; 682 | } 683 | 684 | $this->addRecommendation( 685 | version_compare($version, '4.0', '>='), 686 | 'intl ICU version should be at least 4+', 687 | 'Upgrade your intl extension with a newer ICU version (4+).' 688 | ); 689 | 690 | if (class_exists('Symfony\Component\Intl\Intl')) { 691 | $this->addRecommendation( 692 | \Symfony\Component\Intl\Intl::getIcuDataVersion() <= \Symfony\Component\Intl\Intl::getIcuVersion(), 693 | sprintf('intl ICU version installed on your system is outdated (%s) and does not match the ICU data bundled with Symfony (%s)', \Symfony\Component\Intl\Intl::getIcuVersion(), \Symfony\Component\Intl\Intl::getIcuDataVersion()), 694 | 'To get the latest internationalization data upgrade the ICU system package and the intl PHP extension.' 695 | ); 696 | if (\Symfony\Component\Intl\Intl::getIcuDataVersion() <= \Symfony\Component\Intl\Intl::getIcuVersion()) { 697 | $this->addRecommendation( 698 | \Symfony\Component\Intl\Intl::getIcuDataVersion() === \Symfony\Component\Intl\Intl::getIcuVersion(), 699 | sprintf('intl ICU version installed on your system (%s) does not match the ICU data bundled with Symfony (%s)', \Symfony\Component\Intl\Intl::getIcuVersion(), \Symfony\Component\Intl\Intl::getIcuDataVersion()), 700 | 'To avoid internationalization data inconsistencies upgrade the symfony/intl component.' 701 | ); 702 | } 703 | } 704 | 705 | $this->addPhpIniRecommendation( 706 | 'intl.error_level', 707 | create_function('$cfgValue', 'return (int) $cfgValue === 0;'), 708 | true, 709 | 'intl.error_level should be 0 in php.ini', 710 | 'Set "intl.error_level" to "0" in php.ini* to inhibit the messages when an error occurs in ICU functions.' 711 | ); 712 | } 713 | 714 | $accelerator = 715 | (extension_loaded('eaccelerator') && ini_get('eaccelerator.enable')) 716 | || 717 | (extension_loaded('apc') && ini_get('apc.enabled')) 718 | || 719 | (extension_loaded('Zend Optimizer+') && ini_get('zend_optimizerplus.enable')) 720 | || 721 | (extension_loaded('Zend OPcache') && ini_get('opcache.enable')) 722 | || 723 | (extension_loaded('xcache') && ini_get('xcache.cacher')) 724 | || 725 | (extension_loaded('wincache') && ini_get('wincache.ocenabled')) 726 | ; 727 | 728 | $this->addRecommendation( 729 | $accelerator, 730 | 'a PHP accelerator should be installed', 731 | 'Install and/or enable a PHP accelerator (highly recommended).' 732 | ); 733 | 734 | if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { 735 | $this->addRecommendation( 736 | $this->getRealpathCacheSize() >= 5 * 1024 * 1024, 737 | 'realpath_cache_size should be at least 5M in php.ini', 738 | 'Setting "realpath_cache_size" to e.g. "5242880" or "5M" in php.ini* may improve performance on Windows significantly in some cases.' 739 | ); 740 | } 741 | 742 | $this->addPhpIniRecommendation('short_open_tag', false); 743 | 744 | $this->addPhpIniRecommendation('magic_quotes_gpc', false, true); 745 | 746 | $this->addPhpIniRecommendation('register_globals', false, true); 747 | 748 | $this->addPhpIniRecommendation('session.auto_start', false); 749 | 750 | $this->addRecommendation( 751 | class_exists('PDO'), 752 | 'PDO should be installed', 753 | 'Install PDO (mandatory for Doctrine).' 754 | ); 755 | 756 | if (class_exists('PDO')) { 757 | $drivers = PDO::getAvailableDrivers(); 758 | $this->addRecommendation( 759 | count($drivers) > 0, 760 | sprintf('PDO should have some drivers installed (currently available: %s)', count($drivers) ? implode(', ', $drivers) : 'none'), 761 | 'Install PDO drivers (mandatory for Doctrine).' 762 | ); 763 | } 764 | } 765 | 766 | /** 767 | * Loads realpath_cache_size from php.ini and converts it to int. 768 | * 769 | * (e.g. 16k is converted to 16384 int) 770 | * 771 | * @return int 772 | */ 773 | protected function getRealpathCacheSize() 774 | { 775 | $size = ini_get('realpath_cache_size'); 776 | $size = trim($size); 777 | $unit = ''; 778 | if (!ctype_digit($size)) { 779 | $unit = strtolower(substr($size, -1, 1)); 780 | $size = (int) substr($size, 0, -1); 781 | } 782 | switch ($unit) { 783 | case 'g': 784 | return $size * 1024 * 1024 * 1024; 785 | case 'm': 786 | return $size * 1024 * 1024; 787 | case 'k': 788 | return $size * 1024; 789 | default: 790 | return (int) $size; 791 | } 792 | } 793 | 794 | /** 795 | * Defines PHP required version from Symfony version. 796 | * 797 | * @return string|false The PHP required version or false if it could not be guessed 798 | */ 799 | protected function getPhpRequiredVersion() 800 | { 801 | if (!file_exists($path = __DIR__.'/../composer.lock')) { 802 | return false; 803 | } 804 | 805 | $composerLock = json_decode(file_get_contents($path), true); 806 | foreach ($composerLock['packages'] as $package) { 807 | $name = $package['name']; 808 | if ('symfony/symfony' !== $name && 'symfony/http-kernel' !== $name) { 809 | continue; 810 | } 811 | 812 | return (int) $package['version'][1] > 2 ? self::REQUIRED_PHP_VERSION : self::LEGACY_REQUIRED_PHP_VERSION; 813 | } 814 | 815 | return false; 816 | } 817 | } 818 | -------------------------------------------------------------------------------- /var/cache/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcg-web/graphql-symfony-doctrine-sandbox/d31c3c699a91ce59ab07eab748b8956b918df260/var/cache/.gitkeep -------------------------------------------------------------------------------- /var/logs/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcg-web/graphql-symfony-doctrine-sandbox/d31c3c699a91ce59ab07eab748b8956b918df260/var/logs/.gitkeep -------------------------------------------------------------------------------- /var/sessions/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcg-web/graphql-symfony-doctrine-sandbox/d31c3c699a91ce59ab07eab748b8956b918df260/var/sessions/.gitkeep -------------------------------------------------------------------------------- /web/.htaccess: -------------------------------------------------------------------------------- 1 | # Use the front controller as index file. It serves as a fallback solution when 2 | # every other rewrite/redirect fails (e.g. in an aliased environment without 3 | # mod_rewrite). Additionally, this reduces the matching process for the 4 | # start page (path "/") because otherwise Apache will apply the rewriting rules 5 | # to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl). 6 | DirectoryIndex app.php 7 | 8 | # By default, Apache does not evaluate symbolic links if you did not enable this 9 | # feature in your server configuration. Uncomment the following line if you 10 | # install assets as symlinks or if you experience problems related to symlinks 11 | # when compiling LESS/Sass/CoffeScript assets. 12 | # Options FollowSymlinks 13 | 14 | # Disabling MultiViews prevents unwanted negotiation, e.g. "/app" should not resolve 15 | # to the front controller "/app.php" but be rewritten to "/app.php/app". 16 | 17 | Options -MultiViews 18 | 19 | 20 | 21 | RewriteEngine On 22 | 23 | # Determine the RewriteBase automatically and set it as environment variable. 24 | # If you are using Apache aliases to do mass virtual hosting or installed the 25 | # project in a subdirectory, the base path will be prepended to allow proper 26 | # resolution of the app.php file and to redirect to the correct URI. It will 27 | # work in environments without path prefix as well, providing a safe, one-size 28 | # fits all solution. But as you do not need it in this case, you can comment 29 | # the following 2 lines to eliminate the overhead. 30 | RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ 31 | RewriteRule ^(.*) - [E=BASE:%1] 32 | 33 | # Sets the HTTP_AUTHORIZATION header removed by Apache 34 | RewriteCond %{HTTP:Authorization} . 35 | RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 36 | 37 | # Redirect to URI without front controller to prevent duplicate content 38 | # (with and without `/app.php`). Only do this redirect on the initial 39 | # rewrite by Apache and not on subsequent cycles. Otherwise we would get an 40 | # endless redirect loop (request -> rewrite to front controller -> 41 | # redirect -> request -> ...). 42 | # So in case you get a "too many redirects" error or you always get redirected 43 | # to the start page because your Apache does not expose the REDIRECT_STATUS 44 | # environment variable, you have 2 choices: 45 | # - disable this feature by commenting the following 2 lines or 46 | # - use Apache >= 2.3.9 and replace all L flags by END flags and remove the 47 | # following RewriteCond (best solution) 48 | RewriteCond %{ENV:REDIRECT_STATUS} ^$ 49 | RewriteRule ^app\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L] 50 | 51 | # If the requested filename exists, simply serve it. 52 | # We only want to let Apache serve files and not directories. 53 | RewriteCond %{REQUEST_FILENAME} -f 54 | RewriteRule ^ - [L] 55 | 56 | # Rewrite all other queries to the front controller. 57 | RewriteRule ^ %{ENV:BASE}/app.php [L] 58 | 59 | 60 | 61 | 62 | # When mod_rewrite is not available, we instruct a temporary redirect of 63 | # the start page to the front controller explicitly so that the website 64 | # and the generated links can still be used. 65 | RedirectMatch 302 ^/$ /app.php/ 66 | # RedirectTemp cannot be used instead 67 | 68 | 69 | -------------------------------------------------------------------------------- /web/app.php: -------------------------------------------------------------------------------- 1 | unregister(); 20 | $apcLoader->register(true); 21 | */ 22 | 23 | $kernel = new AppKernel('prod', false); 24 | $kernel->loadClassCache(); 25 | //$kernel = new AppCache($kernel); 26 | 27 | // When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter 28 | //Request::enableHttpMethodParameterOverride(); 29 | $request = Request::createFromGlobals(); 30 | $response = $kernel->handle($request); 31 | $response->send(); 32 | $kernel->terminate($request, $response); 33 | -------------------------------------------------------------------------------- /web/app_dev.php: -------------------------------------------------------------------------------- 1 | loadClassCache(); 29 | $request = Request::createFromGlobals(); 30 | $response = $kernel->handle($request); 31 | $response->send(); 32 | $kernel->terminate($request, $response); 33 | -------------------------------------------------------------------------------- /web/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcg-web/graphql-symfony-doctrine-sandbox/d31c3c699a91ce59ab07eab748b8956b918df260/web/apple-touch-icon.png -------------------------------------------------------------------------------- /web/config.php: -------------------------------------------------------------------------------- 1 | getFailedRequirements(); 30 | $minorProblems = $symfonyRequirements->getFailedRecommendations(); 31 | $hasMajorProblems = (bool) count($majorProblems); 32 | $hasMinorProblems = (bool) count($minorProblems); 33 | 34 | ?> 35 | 36 | 37 | 38 | 39 | 40 | Symfony Configuration Checker 41 | 331 | 332 | 333 |
334 |
335 | 338 | 339 | 359 |
360 | 361 |
362 |
363 |
364 |

Configuration Checker

365 |

366 | This script analyzes your system to check whether is 367 | ready to run Symfony applications. 368 |

369 | 370 | 371 |

Major problems

372 |

Major problems have been detected and must be fixed before continuing:

373 |
    374 | 375 |
  1. getTestMessage() ?> 376 |

    getHelpHtml() ?>

    377 |
  2. 378 | 379 |
380 | 381 | 382 | 383 |

Recommendations

384 |

385 | Additionally, toTo enhance your Symfony experience, 386 | it’s recommended that you fix the following: 387 |

388 |
    389 | 390 |
  1. getTestMessage() ?> 391 |

    getHelpHtml() ?>

    392 |
  2. 393 | 394 |
395 | 396 | 397 | hasPhpIniConfigIssue()): ?> 398 |

* 399 | getPhpIniConfigPath()): ?> 400 | Changes to the php.ini file must be done in "getPhpIniConfigPath() ?>". 401 | 402 | To change settings, create a "php.ini". 403 | 404 |

405 | 406 | 407 | 408 |

All checks passed successfully. Your system is ready to run Symfony applications.

409 | 410 | 411 | 416 |
417 |
418 |
419 |
Symfony Standard Edition
420 |
421 | 422 | 423 | -------------------------------------------------------------------------------- /web/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcg-web/graphql-symfony-doctrine-sandbox/d31c3c699a91ce59ab07eab748b8956b918df260/web/favicon.ico -------------------------------------------------------------------------------- /web/robots.txt: -------------------------------------------------------------------------------- 1 | # www.robotstxt.org/ 2 | # www.google.com/support/webmasters/bin/answer.py?hl=en&answer=156449 3 | 4 | User-agent: * 5 | Disallow: 6 | --------------------------------------------------------------------------------