├── .gitignore ├── LICENSE ├── README.md ├── app ├── .htaccess ├── AppCache.php ├── AppKernel.php ├── Resources │ └── views │ │ └── base.html.twig ├── SymfonyRequirements.php ├── autoload.php ├── check.php ├── config │ ├── config.yml │ ├── config_dev.yml │ ├── config_prod.yml │ ├── config_test.yml │ ├── parameters.yml.dist │ ├── routing.yml │ ├── routing_dev.yml │ └── security.yml ├── console ├── data.db3 └── phpunit.xml.dist ├── composer.json ├── composer.lock ├── src ├── .htaccess ├── AppBundle │ ├── Aop │ │ ├── Transactional.php │ │ ├── TransactionalInterceptor.php │ │ └── TransactionalPointcut.php │ ├── AppBundle.php │ ├── Command │ │ └── CloseSprintCommand.php │ ├── Controller │ │ ├── Api │ │ │ └── SprintController.php │ │ ├── ReportViewAdapter.php │ │ ├── SprintController.php │ │ └── SprintViewAdapter.php │ ├── DataFixtures │ │ └── ORM │ │ │ ├── LoadSprintData.php │ │ │ └── sprints.yml │ ├── DependencyInjection │ │ ├── AppExtension.php │ │ └── Configuration.php │ ├── Repository │ │ ├── IssueRepositoryDoctrine.php │ │ └── SprintRepositoryDoctrine.php │ └── Resources │ │ ├── config │ │ ├── doctrine │ │ │ ├── Issue.Issue.orm.xml │ │ │ └── Sprint.Sprint.orm.xml │ │ ├── routing.yml │ │ └── services.xml │ │ └── views │ │ └── Sprint │ │ ├── close.html.twig │ │ └── show.html.twig ├── Application │ ├── Impl │ │ └── SprintServiceImpl.php │ ├── SprintService.php │ └── TransactionalService.php ├── Domain │ └── Model │ │ ├── Issue │ │ ├── Issue.php │ │ ├── IssueAlreadyClosedException.php │ │ ├── IssueRepository.php │ │ └── IssueStatus.php │ │ └── Sprint │ │ ├── Sprint.php │ │ ├── SprintAlreadyClosedException.php │ │ ├── SprintNotFoundException.php │ │ ├── SprintRepository.php │ │ └── SprintStatus.php └── Interfaces │ └── Sprint │ ├── DTO │ ├── ReportDTO.php │ └── SprintDTO.php │ ├── Internal │ ├── Assembler │ │ ├── ReportDTOAssembler.php │ │ └── SprintDTOAssembler.php │ └── SprintServiceFacadeImpl.php │ └── SprintServiceFacade.php ├── tests ├── Application │ └── Impl │ │ └── SprintServiceTest.php ├── Domain │ └── Model │ │ ├── Issue │ │ ├── IssueStub1.php │ │ ├── IssueStub2.php │ │ └── IssueTest.php │ │ └── Sprint │ │ ├── InMemorySprintRepository.php │ │ ├── SprintStub1.php │ │ └── SprintStub2.php └── bootstrap.php └── web ├── .htaccess ├── app.php ├── app_dev.php ├── apple-touch-icon.png ├── config.php ├── favicon.ico └── robots.txt /.gitignore: -------------------------------------------------------------------------------- 1 | /web/bundles/ 2 | /app/bootstrap.php.cache 3 | /app/cache/* 4 | /app/config/parameters.yml 5 | /app/logs/* 6 | !app/cache/.gitkeep 7 | !app/logs/.gitkeep 8 | /build/ 9 | /vendor/ 10 | /bin/ 11 | /composer.phar 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Romain Kuzniak 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DDD Design with Symfony 2 | This is an example of a Symfony application using DDD design. 3 | The aim is to illustrate the following presentation : 4 | 5 | ## Install 6 | In order to use the application, follow these simple steps. 7 | 8 | ``` bash 9 | composer install 10 | php app/console doctrine:database:create 11 | php app/console doctrine:schema:update --force 12 | php app/console doctrine:fixtures:load 13 | php app/console server:run 14 | ``` 15 | 16 | Go to [http://localhost:8000/sprints/1](http://localhost:8000/sprints/3) 17 | 18 | -------------------------------------------------------------------------------- /app/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | Require all denied 3 | 4 | 5 | Order deny,allow 6 | Deny from all 7 | 8 | -------------------------------------------------------------------------------- /app/AppCache.php: -------------------------------------------------------------------------------- 1 | getEnvironment(), array('dev', 'test'))) { 24 | $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(); 25 | $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle(); 26 | $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle(); 27 | $bundles[] = new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(); 28 | } 29 | 30 | return $bundles; 31 | } 32 | 33 | public function registerContainerConfiguration(LoaderInterface $loader) 34 | { 35 | $loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml'); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/Resources/views/base.html.twig: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {% block title %}Welcome!{% endblock %} 6 | {% block stylesheets %}{% endblock %} 7 | 8 | 9 | 10 | {% for flashMessage in app.session.flashbag.get('error') %} 11 |
12 | {{ flashMessage }} 13 |
14 | {% endfor %} 15 | {% block body %}{% endblock %} 16 | {% block javascripts %}{% endblock %} 17 | 18 | 19 | -------------------------------------------------------------------------------- /app/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 | private $requirements = array(); 172 | 173 | /** 174 | * Gets the current RequirementCollection as an Iterator. 175 | * 176 | * @return Traversable A Traversable interface 177 | */ 178 | public function getIterator() 179 | { 180 | return new ArrayIterator($this->requirements); 181 | } 182 | 183 | /** 184 | * Adds a Requirement. 185 | * 186 | * @param Requirement $requirement A Requirement instance 187 | */ 188 | public function add(Requirement $requirement) 189 | { 190 | $this->requirements[] = $requirement; 191 | } 192 | 193 | /** 194 | * Adds a mandatory requirement. 195 | * 196 | * @param bool $fulfilled Whether the requirement is fulfilled 197 | * @param string $testMessage The message for testing the requirement 198 | * @param string $helpHtml The help text formatted in HTML for resolving the problem 199 | * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) 200 | */ 201 | public function addRequirement($fulfilled, $testMessage, $helpHtml, $helpText = null) 202 | { 203 | $this->add(new Requirement($fulfilled, $testMessage, $helpHtml, $helpText, false)); 204 | } 205 | 206 | /** 207 | * Adds an optional recommendation. 208 | * 209 | * @param bool $fulfilled Whether the recommendation is fulfilled 210 | * @param string $testMessage The message for testing the recommendation 211 | * @param string $helpHtml The help text formatted in HTML for resolving the problem 212 | * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) 213 | */ 214 | public function addRecommendation($fulfilled, $testMessage, $helpHtml, $helpText = null) 215 | { 216 | $this->add(new Requirement($fulfilled, $testMessage, $helpHtml, $helpText, true)); 217 | } 218 | 219 | /** 220 | * Adds a mandatory requirement in form of a php.ini configuration. 221 | * 222 | * @param string $cfgName The configuration name used for ini_get() 223 | * @param bool|callback $evaluation Either a boolean indicating whether the configuration should evaluate to true or false, 224 | or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement 225 | * @param bool $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false. 226 | This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin. 227 | Example: You require a config to be true but PHP later removes this config and defaults it to true internally. 228 | * @param string $testMessage The message for testing the requirement (when null and $evaluation is a boolean a default message is derived) 229 | * @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) 230 | * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) 231 | */ 232 | public function addPhpIniRequirement($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null) 233 | { 234 | $this->add(new PhpIniRequirement($cfgName, $evaluation, $approveCfgAbsence, $testMessage, $helpHtml, $helpText, false)); 235 | } 236 | 237 | /** 238 | * Adds an optional recommendation in form of a php.ini configuration. 239 | * 240 | * @param string $cfgName The configuration name used for ini_get() 241 | * @param bool|callback $evaluation Either a boolean indicating whether the configuration should evaluate to true or false, 242 | or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement 243 | * @param bool $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false. 244 | This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin. 245 | Example: You require a config to be true but PHP later removes this config and defaults it to true internally. 246 | * @param string $testMessage The message for testing the requirement (when null and $evaluation is a boolean a default message is derived) 247 | * @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) 248 | * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) 249 | */ 250 | public function addPhpIniRecommendation($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null) 251 | { 252 | $this->add(new PhpIniRequirement($cfgName, $evaluation, $approveCfgAbsence, $testMessage, $helpHtml, $helpText, true)); 253 | } 254 | 255 | /** 256 | * Adds a requirement collection to the current set of requirements. 257 | * 258 | * @param RequirementCollection $collection A RequirementCollection instance 259 | */ 260 | public function addCollection(RequirementCollection $collection) 261 | { 262 | $this->requirements = array_merge($this->requirements, $collection->all()); 263 | } 264 | 265 | /** 266 | * Returns both requirements and recommendations. 267 | * 268 | * @return array Array of Requirement instances 269 | */ 270 | public function all() 271 | { 272 | return $this->requirements; 273 | } 274 | 275 | /** 276 | * Returns all mandatory requirements. 277 | * 278 | * @return array Array of Requirement instances 279 | */ 280 | public function getRequirements() 281 | { 282 | $array = array(); 283 | foreach ($this->requirements as $req) { 284 | if (!$req->isOptional()) { 285 | $array[] = $req; 286 | } 287 | } 288 | 289 | return $array; 290 | } 291 | 292 | /** 293 | * Returns the mandatory requirements that were not met. 294 | * 295 | * @return array Array of Requirement instances 296 | */ 297 | public function getFailedRequirements() 298 | { 299 | $array = array(); 300 | foreach ($this->requirements as $req) { 301 | if (!$req->isFulfilled() && !$req->isOptional()) { 302 | $array[] = $req; 303 | } 304 | } 305 | 306 | return $array; 307 | } 308 | 309 | /** 310 | * Returns all optional recommendations. 311 | * 312 | * @return array Array of Requirement instances 313 | */ 314 | public function getRecommendations() 315 | { 316 | $array = array(); 317 | foreach ($this->requirements as $req) { 318 | if ($req->isOptional()) { 319 | $array[] = $req; 320 | } 321 | } 322 | 323 | return $array; 324 | } 325 | 326 | /** 327 | * Returns the recommendations that were not met. 328 | * 329 | * @return array Array of Requirement instances 330 | */ 331 | public function getFailedRecommendations() 332 | { 333 | $array = array(); 334 | foreach ($this->requirements as $req) { 335 | if (!$req->isFulfilled() && $req->isOptional()) { 336 | $array[] = $req; 337 | } 338 | } 339 | 340 | return $array; 341 | } 342 | 343 | /** 344 | * Returns whether a php.ini configuration is not correct. 345 | * 346 | * @return bool php.ini configuration problem? 347 | */ 348 | public function hasPhpIniConfigIssue() 349 | { 350 | foreach ($this->requirements as $req) { 351 | if (!$req->isFulfilled() && $req instanceof PhpIniRequirement) { 352 | return true; 353 | } 354 | } 355 | 356 | return false; 357 | } 358 | 359 | /** 360 | * Returns the PHP configuration file (php.ini) path. 361 | * 362 | * @return string|false php.ini file path 363 | */ 364 | public function getPhpIniConfigPath() 365 | { 366 | return get_cfg_var('cfg_file_path'); 367 | } 368 | } 369 | 370 | /** 371 | * This class specifies all requirements and optional recommendations that 372 | * are necessary to run the Symfony Standard Edition. 373 | * 374 | * @author Tobias Schultze 375 | * @author Fabien Potencier 376 | */ 377 | class SymfonyRequirements extends RequirementCollection 378 | { 379 | const REQUIRED_PHP_VERSION = '5.3.3'; 380 | 381 | /** 382 | * Constructor that initializes the requirements. 383 | */ 384 | public function __construct() 385 | { 386 | /* mandatory requirements follow */ 387 | 388 | $installedPhpVersion = phpversion(); 389 | 390 | $this->addRequirement( 391 | version_compare($installedPhpVersion, self::REQUIRED_PHP_VERSION, '>='), 392 | sprintf('PHP version must be at least %s (%s installed)', self::REQUIRED_PHP_VERSION, $installedPhpVersion), 393 | sprintf('You are running PHP version "%s", but Symfony needs at least PHP "%s" to run. 394 | Before using Symfony, upgrade your PHP installation, preferably to the latest version.', 395 | $installedPhpVersion, self::REQUIRED_PHP_VERSION), 396 | sprintf('Install PHP %s or newer (installed version is %s)', self::REQUIRED_PHP_VERSION, $installedPhpVersion) 397 | ); 398 | 399 | $this->addRequirement( 400 | version_compare($installedPhpVersion, '5.3.16', '!='), 401 | 'PHP version must not be 5.3.16 as Symfony won\'t work properly with it', 402 | 'Install PHP 5.3.17 or newer (or downgrade to an earlier PHP version)' 403 | ); 404 | 405 | $this->addRequirement( 406 | is_dir(__DIR__.'/../vendor/composer'), 407 | 'Vendor libraries must be installed', 408 | 'Vendor libraries are missing. Install composer following instructions from http://getcomposer.org/. '. 409 | 'Then run "php composer.phar install" to install them.' 410 | ); 411 | 412 | $cacheDir = is_dir(__DIR__.'/../var/cache') ? __DIR__.'/../var/cache' : __DIR__.'/cache'; 413 | 414 | $this->addRequirement( 415 | is_writable($cacheDir), 416 | 'app/cache/ or var/cache/ directory must be writable', 417 | 'Change the permissions of either "app/cache/" or "var/cache/" directory so that the web server can write into it.' 418 | ); 419 | 420 | $logsDir = is_dir(__DIR__.'/../var/logs') ? __DIR__.'/../var/logs' : __DIR__.'/logs'; 421 | 422 | $this->addRequirement( 423 | is_writable($logsDir), 424 | 'app/logs/ or var/logs/ directory must be writable', 425 | 'Change the permissions of either "app/logs/" or "var/logs/" directory so that the web server can write into it.' 426 | ); 427 | 428 | $this->addPhpIniRequirement( 429 | 'date.timezone', true, false, 430 | 'date.timezone setting must be set', 431 | 'Set the "date.timezone" setting in php.ini* (like Europe/Paris).' 432 | ); 433 | 434 | if (version_compare($installedPhpVersion, self::REQUIRED_PHP_VERSION, '>=')) { 435 | $timezones = array(); 436 | foreach (DateTimeZone::listAbbreviations() as $abbreviations) { 437 | foreach ($abbreviations as $abbreviation) { 438 | $timezones[$abbreviation['timezone_id']] = true; 439 | } 440 | } 441 | 442 | $this->addRequirement( 443 | isset($timezones[@date_default_timezone_get()]), 444 | sprintf('Configured default timezone "%s" must be supported by your installation of PHP', @date_default_timezone_get()), 445 | '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.' 446 | ); 447 | } 448 | 449 | $this->addRequirement( 450 | function_exists('json_encode'), 451 | 'json_encode() must be available', 452 | 'Install and enable the JSON extension.' 453 | ); 454 | 455 | $this->addRequirement( 456 | function_exists('session_start'), 457 | 'session_start() must be available', 458 | 'Install and enable the session extension.' 459 | ); 460 | 461 | $this->addRequirement( 462 | function_exists('ctype_alpha'), 463 | 'ctype_alpha() must be available', 464 | 'Install and enable the ctype extension.' 465 | ); 466 | 467 | $this->addRequirement( 468 | function_exists('token_get_all'), 469 | 'token_get_all() must be available', 470 | 'Install and enable the Tokenizer extension.' 471 | ); 472 | 473 | $this->addRequirement( 474 | function_exists('simplexml_import_dom'), 475 | 'simplexml_import_dom() must be available', 476 | 'Install and enable the SimpleXML extension.' 477 | ); 478 | 479 | if (function_exists('apc_store') && ini_get('apc.enabled')) { 480 | if (version_compare($installedPhpVersion, '5.4.0', '>=')) { 481 | $this->addRequirement( 482 | version_compare(phpversion('apc'), '3.1.13', '>='), 483 | 'APC version must be at least 3.1.13 when using PHP 5.4', 484 | 'Upgrade your APC extension (3.1.13+).' 485 | ); 486 | } else { 487 | $this->addRequirement( 488 | version_compare(phpversion('apc'), '3.0.17', '>='), 489 | 'APC version must be at least 3.0.17', 490 | 'Upgrade your APC extension (3.0.17+).' 491 | ); 492 | } 493 | } 494 | 495 | $this->addPhpIniRequirement('detect_unicode', false); 496 | 497 | if (extension_loaded('suhosin')) { 498 | $this->addPhpIniRequirement( 499 | 'suhosin.executor.include.whitelist', 500 | create_function('$cfgValue', 'return false !== stripos($cfgValue, "phar");'), 501 | false, 502 | 'suhosin.executor.include.whitelist must be configured correctly in php.ini', 503 | 'Add "phar" to suhosin.executor.include.whitelist in php.ini*.' 504 | ); 505 | } 506 | 507 | if (extension_loaded('xdebug')) { 508 | $this->addPhpIniRequirement( 509 | 'xdebug.show_exception_trace', false, true 510 | ); 511 | 512 | $this->addPhpIniRequirement( 513 | 'xdebug.scream', false, true 514 | ); 515 | 516 | $this->addPhpIniRecommendation( 517 | 'xdebug.max_nesting_level', 518 | create_function('$cfgValue', 'return $cfgValue > 100;'), 519 | true, 520 | 'xdebug.max_nesting_level should be above 100 in php.ini', 521 | '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.' 522 | ); 523 | } 524 | 525 | $pcreVersion = defined('PCRE_VERSION') ? (float) PCRE_VERSION : null; 526 | 527 | $this->addRequirement( 528 | null !== $pcreVersion, 529 | 'PCRE extension must be available', 530 | 'Install the PCRE extension (version 8.0+).' 531 | ); 532 | 533 | if (extension_loaded('mbstring')) { 534 | $this->addPhpIniRequirement( 535 | 'mbstring.func_overload', 536 | create_function('$cfgValue', 'return (int) $cfgValue === 0;'), 537 | true, 538 | 'string functions should not be overloaded', 539 | 'Set "mbstring.func_overload" to 0 in php.ini* to disable function overloading by the mbstring extension.' 540 | ); 541 | } 542 | 543 | /* optional recommendations follow */ 544 | 545 | $this->addRecommendation( 546 | file_get_contents(__FILE__) === file_get_contents(__DIR__.'/../vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/skeleton/app/SymfonyRequirements.php'), 547 | 'Requirements file should be up-to-date', 548 | 'Your requirements file is outdated. Run composer install and re-check your configuration.' 549 | ); 550 | 551 | $this->addRecommendation( 552 | version_compare($installedPhpVersion, '5.3.4', '>='), 553 | 'You should use at least PHP 5.3.4 due to PHP bug #52083 in earlier versions', 554 | '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.' 555 | ); 556 | 557 | $this->addRecommendation( 558 | version_compare($installedPhpVersion, '5.3.8', '>='), 559 | 'When using annotations you should have at least PHP 5.3.8 due to PHP bug #55156', 560 | 'Install PHP 5.3.8 or newer if your project uses annotations.' 561 | ); 562 | 563 | $this->addRecommendation( 564 | version_compare($installedPhpVersion, '5.4.0', '!='), 565 | 'You should not use PHP 5.4.0 due to the PHP bug #61453', 566 | '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.' 567 | ); 568 | 569 | $this->addRecommendation( 570 | version_compare($installedPhpVersion, '5.4.11', '>='), 571 | '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)', 572 | 'Install PHP 5.4.11 or newer if your project uses the logout handler from the Symfony Security Component.' 573 | ); 574 | 575 | $this->addRecommendation( 576 | (version_compare($installedPhpVersion, '5.3.18', '>=') && version_compare($installedPhpVersion, '5.4.0', '<')) 577 | || 578 | version_compare($installedPhpVersion, '5.4.8', '>='), 579 | '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', 580 | 'Install PHP 5.3.18+ or PHP 5.4.8+ if you want nice error messages for all fatal errors in the development environment.' 581 | ); 582 | 583 | if (null !== $pcreVersion) { 584 | $this->addRecommendation( 585 | $pcreVersion >= 8.0, 586 | sprintf('PCRE extension should be at least version 8.0 (%s installed)', $pcreVersion), 587 | '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.' 588 | ); 589 | } 590 | 591 | $this->addRecommendation( 592 | class_exists('DomDocument'), 593 | 'PHP-XML module should be installed', 594 | 'Install and enable the PHP-XML module.' 595 | ); 596 | 597 | $this->addRecommendation( 598 | function_exists('mb_strlen'), 599 | 'mb_strlen() should be available', 600 | 'Install and enable the mbstring extension.' 601 | ); 602 | 603 | $this->addRecommendation( 604 | function_exists('iconv'), 605 | 'iconv() should be available', 606 | 'Install and enable the iconv extension.' 607 | ); 608 | 609 | $this->addRecommendation( 610 | function_exists('utf8_decode'), 611 | 'utf8_decode() should be available', 612 | 'Install and enable the XML extension.' 613 | ); 614 | 615 | $this->addRecommendation( 616 | function_exists('filter_var'), 617 | 'filter_var() should be available', 618 | 'Install and enable the filter extension.' 619 | ); 620 | 621 | if (!defined('PHP_WINDOWS_VERSION_BUILD')) { 622 | $this->addRecommendation( 623 | function_exists('posix_isatty'), 624 | 'posix_isatty() should be available', 625 | 'Install and enable the php_posix extension (used to colorize the CLI output).' 626 | ); 627 | } 628 | 629 | $this->addRecommendation( 630 | class_exists('Locale'), 631 | 'intl extension should be available', 632 | 'Install and enable the intl extension (used for validators).' 633 | ); 634 | 635 | if (class_exists('Collator')) { 636 | $this->addRecommendation( 637 | null !== new Collator('fr_FR'), 638 | 'intl extension should be correctly configured', 639 | 'The intl extension does not behave properly. This problem is typical on PHP 5.3.X x64 WIN builds.' 640 | ); 641 | } 642 | 643 | if (class_exists('Locale')) { 644 | if (defined('INTL_ICU_VERSION')) { 645 | $version = INTL_ICU_VERSION; 646 | } else { 647 | $reflector = new ReflectionExtension('intl'); 648 | 649 | ob_start(); 650 | $reflector->info(); 651 | $output = strip_tags(ob_get_clean()); 652 | 653 | preg_match('/^ICU version +(?:=> )?(.*)$/m', $output, $matches); 654 | $version = $matches[1]; 655 | } 656 | 657 | $this->addRecommendation( 658 | version_compare($version, '4.0', '>='), 659 | 'intl ICU version should be at least 4+', 660 | 'Upgrade your intl extension with a newer ICU version (4+).' 661 | ); 662 | } 663 | 664 | $accelerator = 665 | (extension_loaded('eaccelerator') && ini_get('eaccelerator.enable')) 666 | || 667 | (extension_loaded('apc') && ini_get('apc.enabled')) 668 | || 669 | (extension_loaded('Zend Optimizer+') && ini_get('zend_optimizerplus.enable')) 670 | || 671 | (extension_loaded('Zend OPcache') && ini_get('opcache.enable')) 672 | || 673 | (extension_loaded('xcache') && ini_get('xcache.cacher')) 674 | || 675 | (extension_loaded('wincache') && ini_get('wincache.ocenabled')) 676 | ; 677 | 678 | $this->addRecommendation( 679 | $accelerator, 680 | 'a PHP accelerator should be installed', 681 | 'Install and/or enable a PHP accelerator (highly recommended).' 682 | ); 683 | 684 | if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { 685 | $this->addPhpIniRecommendation( 686 | 'realpath_cache_size', 687 | create_function('$cfgValue', 'return (int) $cfgValue > 1000;'), 688 | false, 689 | 'realpath_cache_size should be above 1024 in php.ini', 690 | 'Set "realpath_cache_size" to e.g. "1024" in php.ini* to improve performance on windows.' 691 | ); 692 | } 693 | 694 | $this->addPhpIniRecommendation('short_open_tag', false); 695 | 696 | $this->addPhpIniRecommendation('magic_quotes_gpc', false, true); 697 | 698 | $this->addPhpIniRecommendation('register_globals', false, true); 699 | 700 | $this->addPhpIniRecommendation('session.auto_start', false); 701 | 702 | $this->addRecommendation( 703 | class_exists('PDO'), 704 | 'PDO should be installed', 705 | 'Install PDO (mandatory for Doctrine).' 706 | ); 707 | 708 | if (class_exists('PDO')) { 709 | $drivers = PDO::getAvailableDrivers(); 710 | $this->addRecommendation( 711 | count($drivers) > 0, 712 | sprintf('PDO should have some drivers installed (currently available: %s)', count($drivers) ? implode(', ', $drivers) : 'none'), 713 | 'Install PDO drivers (mandatory for Doctrine).' 714 | ); 715 | } 716 | } 717 | } 718 | -------------------------------------------------------------------------------- /app/autoload.php: -------------------------------------------------------------------------------- 1 | getPhpIniConfigPath(); 8 | 9 | echo_title('Symfony2 Requirements Checker'); 10 | 11 | echo '> PHP is using the following php.ini file:'.PHP_EOL; 12 | if ($iniPath) { 13 | echo_style('green', ' '.$iniPath); 14 | } else { 15 | echo_style('warning', ' WARNING: No configuration file (php.ini) used by PHP!'); 16 | } 17 | 18 | echo PHP_EOL.PHP_EOL; 19 | 20 | echo '> Checking Symfony requirements:'.PHP_EOL.' '; 21 | 22 | $messages = array(); 23 | foreach ($symfonyRequirements->getRequirements() as $req) { 24 | /** @var $req Requirement */ 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 Symfony2 projects', true); 46 | } else { 47 | echo_block('error', 'ERROR', 'Your system is not ready to run Symfony2 projects', true); 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).PHP_EOL); 124 | echo_style($style, str_pad(' ['.$title.']', $width, ' ', STR_PAD_RIGHT).PHP_EOL); 125 | echo_style($style, str_pad($message, $width, ' ', STR_PAD_RIGHT).PHP_EOL); 126 | echo_style($style, str_repeat(' ', $width).PHP_EOL); 127 | } 128 | 129 | function has_color_support() 130 | { 131 | static $support; 132 | 133 | if (null === $support) { 134 | if (DIRECTORY_SEPARATOR == '\\') { 135 | $support = false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI'); 136 | } else { 137 | $support = function_exists('posix_isatty') && @posix_isatty(STDOUT); 138 | } 139 | } 140 | 141 | return $support; 142 | } 143 | -------------------------------------------------------------------------------- /app/config/config.yml: -------------------------------------------------------------------------------- 1 | imports: 2 | - { resource: parameters.yml } 3 | - { resource: security.yml } 4 | 5 | services: 6 | twig.extension.intl: 7 | class: Twig_Extensions_Extension_Intl 8 | tags: 9 | - { name: twig.extension } 10 | framework: 11 | #esi: ~ 12 | #translator: { fallback: "%locale%" } 13 | secret: "%secret%" 14 | router: 15 | resource: "%kernel.root_dir%/config/routing.yml" 16 | strict_requirements: ~ 17 | form: ~ 18 | csrf_protection: ~ 19 | validation: { enable_annotations: true } 20 | templating: 21 | engines: ['twig'] 22 | #assets_version: SomeVersionScheme 23 | default_locale: "%locale%" 24 | trusted_hosts: ~ 25 | trusted_proxies: ~ 26 | session: 27 | # handler_id set to null will use default session handler from php.ini 28 | handler_id: ~ 29 | fragments: ~ 30 | http_method_override: true 31 | 32 | # Twig Configuration 33 | twig: 34 | debug: "%kernel.debug%" 35 | strict_variables: "%kernel.debug%" 36 | 37 | # Assetic Configuration 38 | assetic: 39 | debug: "%kernel.debug%" 40 | use_controller: false 41 | bundles: [ ] 42 | #java: /usr/bin/java 43 | filters: 44 | cssrewrite: ~ 45 | #closure: 46 | # jar: "%kernel.root_dir%/Resources/java/compiler.jar" 47 | #yui_css: 48 | # jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar" 49 | 50 | # Doctrine Configuration 51 | doctrine: 52 | dbal: 53 | driver: "%database_driver%" 54 | host: "%database_host%" 55 | port: "%database_port%" 56 | dbname: "%database_name%" 57 | user: "%database_user%" 58 | password: "%database_password%" 59 | charset: UTF8 60 | # if using pdo_sqlite as your database driver: 61 | # 1. add the path in parameters.yml 62 | # e.g. database_path: "%kernel.root_dir%/data/data.db3" 63 | # 2. Uncomment database_path in parameters.yml.dist 64 | # 3. Uncomment next line: 65 | path: "%database_path%" 66 | 67 | orm: 68 | auto_generate_proxy_classes: "%kernel.debug%" 69 | mappings: 70 | Acme: 71 | type: xml 72 | is_bundle: false 73 | dir: %kernel.root_dir%/../src/AppBundle/Resources/config/doctrine 74 | prefix: Domain\Model 75 | alias: Domain 76 | 77 | # Swiftmailer Configuration 78 | swiftmailer: 79 | transport: "%mailer_transport%" 80 | host: "%mailer_host%" 81 | username: "%mailer_user%" 82 | password: "%mailer_password%" 83 | spool: { type: memory } 84 | 85 | jms_aop: 86 | cache_dir: %kernel.cache_dir%/jms_aop 87 | -------------------------------------------------------------------------------- /app/config/config_dev.yml: -------------------------------------------------------------------------------- 1 | imports: 2 | - { resource: config.yml } 3 | 4 | framework: 5 | router: 6 | resource: "%kernel.root_dir%/config/routing_dev.yml" 7 | strict_requirements: true 8 | profiler: { only_exceptions: false } 9 | 10 | web_profiler: 11 | toolbar: "%debug_toolbar%" 12 | intercept_redirects: "%debug_redirects%" 13 | 14 | monolog: 15 | handlers: 16 | main: 17 | type: stream 18 | path: "%kernel.logs_dir%/%kernel.environment%.log" 19 | level: debug 20 | console: 21 | type: console 22 | bubble: false 23 | # uncomment to get logging in your browser 24 | # you may have to allow bigger header sizes in your Web server configuration 25 | #firephp: 26 | # type: firephp 27 | # level: info 28 | #chromephp: 29 | # type: chromephp 30 | # level: info 31 | 32 | assetic: 33 | use_controller: "%use_assetic_controller%" 34 | 35 | #swiftmailer: 36 | # delivery_address: me@example.com 37 | -------------------------------------------------------------------------------- /app/config/config_prod.yml: -------------------------------------------------------------------------------- 1 | imports: 2 | - { resource: config.yml } 3 | 4 | #framework: 5 | # validation: 6 | # cache: apc 7 | 8 | #doctrine: 9 | # orm: 10 | # metadata_cache_driver: apc 11 | # result_cache_driver: apc 12 | # query_cache_driver: apc 13 | 14 | monolog: 15 | handlers: 16 | main: 17 | type: fingers_crossed 18 | action_level: error 19 | handler: nested 20 | nested: 21 | type: stream 22 | path: "%kernel.logs_dir%/%kernel.environment%.log" 23 | level: debug 24 | console: 25 | type: console 26 | -------------------------------------------------------------------------------- /app/config/config_test.yml: -------------------------------------------------------------------------------- 1 | imports: 2 | - { resource: config_dev.yml } 3 | 4 | framework: 5 | test: ~ 6 | session: 7 | storage_id: session.storage.mock_file 8 | profiler: 9 | collect: false 10 | 11 | web_profiler: 12 | toolbar: false 13 | intercept_redirects: false 14 | 15 | swiftmailer: 16 | disable_delivery: true 17 | -------------------------------------------------------------------------------- /app/config/parameters.yml.dist: -------------------------------------------------------------------------------- 1 | parameters: 2 | database_driver: pdo_sqlite 3 | database_host: 127.0.0.1 4 | database_port: ~ 5 | database_name: symfony 6 | database_user: root 7 | database_password: ~ 8 | # You should uncomment this if you want use pdo_sqlite 9 | database_path: "%kernel.root_dir%/data.db3" 10 | 11 | mailer_transport: smtp 12 | mailer_host: 127.0.0.1 13 | mailer_user: ~ 14 | mailer_password: ~ 15 | 16 | locale: en 17 | secret: ThisTokenIsNotSoSecretChangeIt 18 | 19 | debug_toolbar: true 20 | debug_redirects: false 21 | use_assetic_controller: true 22 | -------------------------------------------------------------------------------- /app/config/routing.yml: -------------------------------------------------------------------------------- 1 | app: 2 | resource: "@AppBundle/Resources/config/routing.yml" 3 | prefix: / 4 | 5 | -------------------------------------------------------------------------------- /app/config/routing_dev.yml: -------------------------------------------------------------------------------- 1 | _wdt: 2 | resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml" 3 | prefix: /_wdt 4 | 5 | _profiler: 6 | resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml" 7 | prefix: /_profiler 8 | 9 | _configurator: 10 | resource: "@SensioDistributionBundle/Resources/config/routing/webconfigurator.xml" 11 | prefix: /_configurator 12 | 13 | _main: 14 | resource: routing.yml 15 | -------------------------------------------------------------------------------- /app/config/security.yml: -------------------------------------------------------------------------------- 1 | security: 2 | providers: 3 | in_memory: 4 | memory: ~ 5 | 6 | firewalls: 7 | dev: 8 | pattern: ^/(_(profiler|wdt)|css|images|js)/ 9 | security: false 10 | 11 | default: 12 | anonymous: ~ 13 | -------------------------------------------------------------------------------- /app/console: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | getParameterOption(array('--env', '-e'), getenv('SYMFONY_ENV') ?: 'dev'); 19 | $debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(array('--no-debug', '')) && $env !== 'prod'; 20 | 21 | if ($debug) { 22 | Debug::enable(); 23 | } 24 | 25 | $kernel = new AppKernel($env, $debug); 26 | $application = new Application($kernel); 27 | $application->run($input); 28 | -------------------------------------------------------------------------------- /app/data.db3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/romainkuzniak/symfony-ddd/c3b49ffef3dd7156a9f11114b928d415de063b30/app/data.db3 -------------------------------------------------------------------------------- /app/phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | ../tests/* 13 | 14 | 15 | 16 | 21 | 22 | 23 | 24 | ../src 25 | 26 | ../tests/* 27 | ../src/*/*Bundle/Resources 28 | ../src/*/*Bundle/Tests 29 | ../src/*/Bundle/*Bundle/Resources 30 | ../src/*/Bundle/*Bundle/Tests 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "turn-it-up/symfony-ddd", 3 | "license": "MIT", 4 | "type": "project", 5 | "description": "The DDD design with symfony", 6 | "autoload": { 7 | "psr-0": {"": "src/", "SymfonyStandard": "app/"} 8 | }, 9 | "autoload-dev": { 10 | "psr-0": {"": "tests/"} 11 | }, 12 | "require": { 13 | "php": ">=5.3.3", 14 | "symfony/symfony": "2.6.*", 15 | "doctrine/orm": "~2.2,>=2.2.3", 16 | "doctrine/doctrine-bundle": "~1.2", 17 | "jms/aop-bundle": "~1.0", 18 | "twig/extensions": "~1.0", 19 | "symfony/assetic-bundle": "~2.3", 20 | "symfony/swiftmailer-bundle": "~2.3", 21 | "symfony/monolog-bundle": "~2.4", 22 | "sensio/distribution-bundle": "~3.0", 23 | "sensio/framework-extra-bundle": "~3.0", 24 | "incenteev/composer-parameter-handler": "~2.0", 25 | "nesbot/carbon": "~1" 26 | }, 27 | "require-dev": { 28 | "phpunit/phpunit": "~4.3", 29 | "sensio/generator-bundle": "~2.3", 30 | "doctrine/doctrine-fixtures-bundle": "~2.2", 31 | "nelmio/alice": "~1" 32 | }, 33 | "scripts": { 34 | "post-root-package-install": [ 35 | "SymfonyStandard\\Composer::hookRootPackageInstall" 36 | ], "post-install-cmd": [ 37 | "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters", 38 | "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap", 39 | "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache", 40 | "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets", 41 | "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile", 42 | "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles" 43 | ], "post-update-cmd": [ 44 | "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters", 45 | "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap", 46 | "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache", 47 | "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets", 48 | "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile", 49 | "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles" 50 | ] 51 | }, 52 | "config": { 53 | "bin-dir": "bin" 54 | }, 55 | "extra": { 56 | "symfony-app-dir": "app", "symfony-web-dir": "web", "incenteev-parameters": { 57 | "file": "app/config/parameters.yml" 58 | }, "branch-alias": { 59 | "dev-master": "2.5-dev" 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | Require all denied 3 | 4 | 5 | Order deny,allow 6 | Deny from all 7 | 8 | -------------------------------------------------------------------------------- /src/AppBundle/Aop/Transactional.php: -------------------------------------------------------------------------------- 1 | 7 | * @Annotation 8 | */ 9 | class Transactional 10 | { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/AppBundle/Aop/TransactionalInterceptor.php: -------------------------------------------------------------------------------- 1 | 11 | */ 12 | class TransactionalInterceptor implements MethodInterceptorInterface 13 | { 14 | 15 | /** 16 | * @var EntityManager 17 | */ 18 | private $em; 19 | 20 | public function __construct(EntityManager $em) 21 | { 22 | $this->em = $em; 23 | } 24 | 25 | /** 26 | * @return mixed 27 | * @throws \Doctrine\DBAL\ConnectionException 28 | * @throws \Exception 29 | */ 30 | public function intercept(MethodInvocation $invocation) 31 | { 32 | $this->em->getConnection()->beginTransaction(); 33 | try { 34 | $rs = $invocation->proceed(); 35 | 36 | $this->em->flush(); 37 | $this->em->getConnection()->commit(); 38 | 39 | return $rs; 40 | } catch (\Exception $e) { 41 | $this->em->getConnection()->rollBack(); 42 | throw $e; 43 | } 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/AppBundle/Aop/TransactionalPointcut.php: -------------------------------------------------------------------------------- 1 | 10 | */ 11 | class TransactionalPointcut implements PointcutInterface 12 | { 13 | 14 | /** 15 | * @var Reader 16 | */ 17 | private $reader; 18 | 19 | public function __construct(Reader $reader) 20 | { 21 | $this->reader = $reader; 22 | } 23 | 24 | /** 25 | * @return bool 26 | */ 27 | public function matchesClass(\ReflectionClass $class) 28 | { 29 | return $class->implementsInterface('Application\TransactionalService'); 30 | } 31 | 32 | /** 33 | * @return bool 34 | */ 35 | public function matchesMethod(\ReflectionMethod $method) 36 | { 37 | return null !== $this->reader->getMethodAnnotation( 38 | $method, 39 | 'AppBundle\Aop\Transactional' 40 | ); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/AppBundle/AppBundle.php: -------------------------------------------------------------------------------- 1 | 9 | */ 10 | class AppBundle extends Bundle 11 | { 12 | } 13 | -------------------------------------------------------------------------------- /src/AppBundle/Command/CloseSprintCommand.php: -------------------------------------------------------------------------------- 1 | 12 | */ 13 | class CloseSprintCommand extends ContainerAwareCommand 14 | { 15 | protected function configure() 16 | { 17 | $this 18 | ->setName('agility-board:close-sprint') 19 | ->setDescription('Close sprint'); 20 | } 21 | 22 | protected function execute(InputInterface $input, OutputInterface $output) 23 | { 24 | try { 25 | $sprintId = $this->getContainer()->get('service.sprint')->closeExpectedSprint(); 26 | 27 | $output->writeln('Close Sprint: ' . $sprintId); 28 | } catch (NoResultException $nre) { 29 | $output->writeln('None'); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/AppBundle/Controller/Api/SprintController.php: -------------------------------------------------------------------------------- 1 | 14 | */ 15 | class SprintController extends Controller 16 | { 17 | /** 18 | * @param int $id 19 | * 20 | * @return \Symfony\Component\HttpFoundation\Response 21 | */ 22 | public function closeAction($id) 23 | { 24 | try { 25 | $report = $this->get('facade.service.sprint')->closeSprint($id); 26 | 27 | return new JsonResponse($report); 28 | } catch (SprintNotFoundException $snfe) { 29 | throw new NotFoundHttpException(); 30 | } catch (SprintAlreadyClosedException $sace) { 31 | return new JsonResponse('Sprint already closed', Response::HTTP_UNPROCESSABLE_ENTITY); 32 | } 33 | } 34 | 35 | /** 36 | * @param int $id 37 | * 38 | * @return \Symfony\Component\HttpFoundation\Response 39 | */ 40 | public function getAction($id) 41 | { 42 | try { 43 | $sprint = $this->get('facade.service.sprint')->get($id); 44 | 45 | return new Response( 46 | json_encode($sprint), 47 | Response::HTTP_OK, 48 | array('Content-type' => 'application/json') 49 | ); 50 | } catch (SprintNotFoundException $snfe) { 51 | throw new NotFoundHttpException(); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/AppBundle/Controller/ReportViewAdapter.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | class ReportViewAdapter 9 | { 10 | 11 | /** 12 | * @var array 13 | */ 14 | private $report; 15 | 16 | public function __construct(array $report) 17 | { 18 | $this->report = $report; 19 | } 20 | 21 | /** 22 | * int 23 | */ 24 | public function getSprintId() 25 | { 26 | return $this->report['sprintId']; 27 | } 28 | 29 | /** 30 | * @return float 31 | */ 32 | public function getAverageClosedIssues() 33 | { 34 | return $this->report['averageClosedIssues']; 35 | } 36 | 37 | /** 38 | * @return int 39 | */ 40 | public function getClosedIssuesCount() 41 | { 42 | return $this->report['closedIssuesCount']; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/AppBundle/Controller/SprintController.php: -------------------------------------------------------------------------------- 1 | 12 | */ 13 | class SprintController extends Controller 14 | { 15 | /** 16 | * @param int $id 17 | * 18 | * @return \Symfony\Component\HttpFoundation\Response 19 | */ 20 | public function closeAction($id) 21 | { 22 | try { 23 | $report = $this->get('service.sprint')->closeSprint($id); 24 | 25 | return $this->render( 26 | 'AppBundle:Sprint:close.html.twig', 27 | array('report' => new ReportViewAdapter($report)) 28 | ); 29 | } catch (SprintAlreadyClosedException $sace) { 30 | $this->get('session')->getFlashBag()->add('error', 'Sprint already closed'); 31 | 32 | return $this->redirect($this->generateUrl('show_sprint', array('id' => $id))); 33 | } catch (SprintNotFoundException $snfe) { 34 | throw new NotFoundHttpException(); 35 | } 36 | } 37 | 38 | /** 39 | * @param int $id 40 | * 41 | * @return \Symfony\Component\HttpFoundation\Response 42 | */ 43 | public function showAction($id) 44 | { 45 | try { 46 | $sprint = $this->get('service.sprint')->get($id); 47 | 48 | return $this->render( 49 | 'AppBundle:Sprint:show.html.twig', 50 | array('sprint' => new SprintViewAdapter($sprint)) 51 | ); 52 | } catch (SprintNotFoundException $snfe) { 53 | throw new NotFoundHttpException(); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/AppBundle/Controller/SprintViewAdapter.php: -------------------------------------------------------------------------------- 1 | 9 | */ 10 | class SprintViewAdapter 11 | { 12 | 13 | /** 14 | * @var Sprint 15 | */ 16 | private $sprint; 17 | 18 | public function __construct(Sprint $sprint) 19 | { 20 | $this->sprint = $sprint; 21 | } 22 | 23 | /** 24 | * @return \DateTime 25 | */ 26 | public function getCreatedAt() 27 | { 28 | return null === $this->sprint->getCreatedAt() ? null : 29 | $this->sprint->getCreatedAt()->format(\DateTime::ISO8601); 30 | } 31 | 32 | /** 33 | * @return integer 34 | */ 35 | public function getId() 36 | { 37 | return $this->sprint->getId(); 38 | } 39 | 40 | /** 41 | * @return \DateTime 42 | */ 43 | public function getEffectiveClosedAt() 44 | { 45 | return null === $this->sprint->getEffectiveClosedAt() ? null : 46 | $this->sprint->getEffectiveClosedAt()->format(\DateTime::ISO8601); 47 | } 48 | 49 | /** 50 | * @return \DateTime 51 | */ 52 | public function getExpectedClosedAt() 53 | { 54 | return null === $this->sprint->getExpectedClosedAt() ? null : 55 | $this->sprint->getExpectedClosedAt()->format(\DateTime::ISO8601); 56 | } 57 | 58 | /** 59 | * @return string 60 | */ 61 | public function getStatus() 62 | { 63 | return $this->sprint->getStatus(); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/AppBundle/DataFixtures/ORM/LoadSprintData.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | class LoadSprintData extends AbstractFixture implements OrderedFixtureInterface 15 | { 16 | 17 | /** 18 | * @var int 19 | */ 20 | public static $i = 0; 21 | 22 | /** 23 | * Load data fixtures with the passed EntityManager 24 | * 25 | * @param \Doctrine\Common\Persistence\ObjectManager $manager 26 | */ 27 | public function load(ObjectManager $manager) 28 | { 29 | Fixtures::load(__DIR__ . '/sprints.yml', $manager, array('providers' => array($this))); 30 | } 31 | 32 | public function expectedClosedAt() 33 | { 34 | return new \DateTime(Carbon::now()->addDay()->toDateTimeString()); 35 | } 36 | 37 | /** 38 | * @return string 39 | */ 40 | public function status() 41 | { 42 | return ++self::$i % 2 ? 'DONE' : 'OPEN'; 43 | } 44 | 45 | /** 46 | * @return string 47 | */ 48 | public function doneAt() 49 | { 50 | return self::$i % 2 ? new \DateTime(Carbon::now()->toDateTimeString()) : null; 51 | } 52 | 53 | /** 54 | * Get the order of this fixture 55 | * 56 | * @return integer 57 | */ 58 | public function getOrder() 59 | { 60 | return 1; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/AppBundle/DataFixtures/ORM/sprints.yml: -------------------------------------------------------------------------------- 1 | Domain\Model\Sprint\Sprint: 2 | sprint_1: 3 | status: "CLOSE" 4 | effectiveClosedAt: 5 | expectedClosedAt: 6 | sprint_2: 7 | status: "CLOSE" 8 | effectiveClosedAt: 9 | expectedClosedAt: 10 | sprint_3: 11 | status: "OPEN" 12 | expectedClosedAt: 13 | Domain\Model\Issue\Issue: 14 | issue{1..15}: 15 | title: Issue 16 | description: 17 | sprint: @sprint_1 18 | status: CLOSE 19 | createdAt: 20 | doneAt: 21 | closedAt: 22 | issue{16..20}: 23 | title: Issue 24 | description: 25 | sprint: @sprint_2 26 | status: CLOSE 27 | createdAt: 28 | doneAt: 29 | closedAt: 30 | issue{21..30}: 31 | title: Issue 32 | description: 33 | sprint: @sprint_3 34 | status: 35 | doneAt: 36 | -------------------------------------------------------------------------------- /src/AppBundle/DependencyInjection/AppExtension.php: -------------------------------------------------------------------------------- 1 | processConfiguration($configuration, $configs); 24 | 25 | $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); 26 | $loader->load('services.xml'); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/AppBundle/DependencyInjection/Configuration.php: -------------------------------------------------------------------------------- 1 | root('turn_it_up_agility_board'); 22 | 23 | // Here you should define the parameters that are allowed to 24 | // configure your bundle. See the documentation linked above for 25 | // more information on that topic. 26 | return $treeBuilder; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/AppBundle/Repository/IssueRepositoryDoctrine.php: -------------------------------------------------------------------------------- 1 | 10 | */ 11 | class IssueRepositoryDoctrine extends EntityRepository implements IssueRepository 12 | { 13 | } 14 | -------------------------------------------------------------------------------- /src/AppBundle/Repository/SprintRepositoryDoctrine.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | class SprintRepositoryDoctrine extends EntityRepository implements SprintRepository 17 | { 18 | /** 19 | * @return \Domain\Model\Sprint\Sprint 20 | * @throws SprintNotFoundException 21 | */ 22 | public function find($id) 23 | { 24 | $sprint = parent::find($id); 25 | 26 | if (null === $sprint) { 27 | throw new SprintNotFoundException(); 28 | } 29 | 30 | return $sprint; 31 | } 32 | 33 | /** 34 | * @return Sprint 35 | * 36 | * @throws SprintNotFoundException 37 | * @throws \Doctrine\ORM\NonUniqueResultException 38 | */ 39 | public function findSprintToClose() 40 | { 41 | try { 42 | return $this->createQueryBuilder('s') 43 | ->andWhere('s.expectedClosedAt < :now') 44 | ->setParameter('now', new \DateTime(Carbon::now()->toDateTimeString())) 45 | ->andWhere('s.status != :status') 46 | ->setParameter('status', SprintStatus::CLOSE) 47 | ->getQuery() 48 | ->getSingleResult(); 49 | } catch (NoResultException $nre) { 50 | throw new SprintNotFoundException(); 51 | } 52 | } 53 | 54 | /** 55 | * @return int 56 | */ 57 | public function findAverageClosedIssues() 58 | { 59 | return (int) $this->createQueryBuilder('s') 60 | ->select('AVG(i.id) as averageClosedIssues') 61 | ->leftJoin('s.issues', 'i') 62 | ->andWhere('s.status = :status') 63 | ->setParameter('status', SprintStatus::CLOSE) 64 | ->getQuery() 65 | ->getSingleScalarResult(); 66 | } 67 | 68 | public function update(Sprint $sprint) 69 | { 70 | 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/AppBundle/Resources/config/doctrine/Issue.Issue.orm.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/AppBundle/Resources/config/doctrine/Sprint.Sprint.orm.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/AppBundle/Resources/config/routing.yml: -------------------------------------------------------------------------------- 1 | show_sprint: 2 | path: /sprints/{id} 3 | defaults: 4 | _controller: AppBundle:Sprint:show 5 | requirements: 6 | id: \d+ 7 | _method: GET 8 | 9 | close_sprint: 10 | path: /sprints/{id}/close 11 | defaults: 12 | _controller: AppBundle:Sprint:close 13 | requirements: 14 | id: \d+ 15 | _method: POST 16 | 17 | api_get_sprint: 18 | path: /api/sprints/{id} 19 | defaults: 20 | _controller: AppBundle:Api/Sprint:get 21 | requirements: 22 | id: \d+ 23 | _method: GET 24 | 25 | api_close_sprint: 26 | path: /api/sprints/{id}/close 27 | defaults: 28 | _controller: AppBundle:Api/Sprint:close 29 | requirements: 30 | id: \d+ 31 | _method: POST 32 | -------------------------------------------------------------------------------- /src/AppBundle/Resources/config/services.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | Domain\Model\Sprint\Sprint 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/AppBundle/Resources/views/Sprint/close.html.twig: -------------------------------------------------------------------------------- 1 | {% extends 'base.html.twig' %} 2 | {% block body %} 3 |

Sprint : {{ report.sprintId }}

4 |

Average Closed Issues (all previous sprints): {{ report.averageClosedIssues }}

5 |

Closed Issues : {{ report.closedIssuesCount }}

6 | {% endblock %} 7 | -------------------------------------------------------------------------------- /src/AppBundle/Resources/views/Sprint/show.html.twig: -------------------------------------------------------------------------------- 1 | {% extends 'base.html.twig' %} 2 | {% block body %} 3 |

SPRINT {{ sprint.id }}

4 |

Status : {{ sprint.status }}

5 |

Creation date : {{ sprint.createdAt | localizeddate }}

6 |

Expected closed date : {{ sprint.expectedClosedAt |localizeddate }}

7 | {% if sprint.effectiveClosedAt is not empty %} 8 |

Effective closed date : {{ sprint.effectiveClosedAt |localizeddate }}

9 | {% endif %} 10 | 11 |
12 | 13 |
14 | {% endblock %} 15 | -------------------------------------------------------------------------------- /src/Application/Impl/SprintServiceImpl.php: -------------------------------------------------------------------------------- 1 | 12 | */ 13 | class SprintServiceImpl implements SprintService 14 | { 15 | 16 | /** 17 | * @var SprintRepository 18 | */ 19 | private $sprintRepository; 20 | 21 | /** 22 | * @Transactional 23 | * @return array 24 | * @throws \Domain\Model\Sprint\SprintNotFoundException 25 | * @throws \Domain\Model\Sprint\SprintAlreadyClosedException 26 | */ 27 | public function closeSprint($id) 28 | { 29 | 30 | $sprint = $this->sprintRepository->find($id); 31 | $sprint->close(); 32 | $this->sprintRepository->update($sprint); 33 | 34 | $closedIssuesCount = $sprint->getIssues()->count(); 35 | 36 | return array( 37 | 'sprintId' => $sprint->getId(), 38 | 'closedIssuesCount' => $closedIssuesCount, 39 | 'averageClosedIssues' => $this->sprintRepository->findAverageClosedIssues() 40 | ); 41 | } 42 | 43 | /** 44 | * @Transactional 45 | * @return int 46 | * @throws \Domain\Model\Sprint\SprintNotFoundException 47 | * @throws \Domain\Model\Sprint\SprintAlreadyClosedException 48 | */ 49 | public function closeExpectedSprint() 50 | { 51 | $sprint = $this->sprintRepository->findSprintToClose(); 52 | $sprint->close(); 53 | $this->sprintRepository->update($sprint); 54 | 55 | return $sprint->getId(); 56 | } 57 | 58 | /** 59 | * @return \Domain\Model\Sprint\Sprint 60 | * @throws \Domain\Model\Sprint\SprintNotFoundException 61 | */ 62 | public function get($id) 63 | { 64 | return $this->sprintRepository->find($id); 65 | } 66 | 67 | public function setSprintRepository(SprintRepositoryDoctrine $sprintRepository) 68 | { 69 | $this->sprintRepository = $sprintRepository; 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/Application/SprintService.php: -------------------------------------------------------------------------------- 1 | 10 | */ 11 | interface SprintService extends TransactionalService 12 | { 13 | /** 14 | * @return array 15 | * @throws \Domain\Model\Sprint\SprintNotFoundException 16 | * @throws SprintAlreadyClosedException 17 | */ 18 | public function closeSprint($id); 19 | 20 | /** 21 | * @return int 22 | * @throws SprintNotFoundException 23 | * @throws \Domain\Model\Sprint\SprintAlreadyClosedException 24 | */ 25 | public function closeExpectedSprint(); 26 | 27 | /** 28 | * @return Sprint 29 | * @throws \Domain\Model\Sprint\SprintNotFoundException 30 | */ 31 | public function get($id); 32 | } 33 | -------------------------------------------------------------------------------- /src/Application/TransactionalService.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | interface TransactionalService 9 | { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/Domain/Model/Issue/Issue.php: -------------------------------------------------------------------------------- 1 | 10 | */ 11 | class Issue 12 | { 13 | 14 | /** 15 | * @var integer 16 | */ 17 | protected $id; 18 | 19 | /** 20 | * @var string 21 | */ 22 | protected $status; 23 | 24 | /** 25 | * @var string 26 | */ 27 | protected $title; 28 | 29 | /** 30 | * @var string 31 | */ 32 | protected $description; 33 | 34 | /** 35 | * @var \DateTime 36 | */ 37 | protected $createdAt; 38 | 39 | /** 40 | * @var string 41 | */ 42 | protected $doneAt; 43 | 44 | /** 45 | * @var \DateTime 46 | */ 47 | protected $closedAt; 48 | 49 | /** 50 | * @var Sprint 51 | */ 52 | protected $sprint; 53 | 54 | public function __construct() 55 | { 56 | $this->createdAt = new \DateTime(Carbon::now()->toTimeString()); 57 | } 58 | 59 | /** 60 | * @return integer 61 | */ 62 | public function getId() 63 | { 64 | return $this->id; 65 | } 66 | 67 | /** 68 | * @return string 69 | */ 70 | public function getTitle() 71 | { 72 | return $this->title; 73 | } 74 | 75 | /** 76 | * @return string 77 | */ 78 | public function getDescription() 79 | { 80 | return $this->description; 81 | } 82 | 83 | /** 84 | * @return \DateTime 85 | */ 86 | public function getCreatedAt() 87 | { 88 | return $this->createdAt; 89 | } 90 | 91 | /** 92 | * @return string 93 | */ 94 | public function getDoneAt() 95 | { 96 | return $this->doneAt; 97 | } 98 | 99 | /** 100 | * @return \DateTime 101 | */ 102 | public function getClosedAt() 103 | { 104 | return $this->closedAt; 105 | } 106 | 107 | /** 108 | * @return bool 109 | */ 110 | public function isDone() 111 | { 112 | return IssueStatus::DONE === $this->getStatus(); 113 | } 114 | 115 | /** 116 | * @return string 117 | */ 118 | public function getStatus() 119 | { 120 | return $this->status; 121 | } 122 | 123 | public function close() 124 | { 125 | if ($this->isClosed()) { 126 | throw new IssueAlreadyClosedException(); 127 | } 128 | 129 | $this->closedAt = new \DateTime(); 130 | $this->status = IssueStatus::CLOSE; 131 | } 132 | 133 | /** 134 | * @return bool 135 | */ 136 | public function isClosed() 137 | { 138 | return IssueStatus::CLOSE === $this->getStatus(); 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /src/Domain/Model/Issue/IssueAlreadyClosedException.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | class IssueAlreadyClosedException extends \Exception 9 | { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/Domain/Model/Issue/IssueRepository.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | interface IssueRepository 9 | { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/Domain/Model/Issue/IssueStatus.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | class IssueStatus 9 | { 10 | const DONE = 'DONE'; 11 | 12 | const CLOSE = 'CLOSE'; 13 | } 14 | -------------------------------------------------------------------------------- /src/Domain/Model/Sprint/Sprint.php: -------------------------------------------------------------------------------- 1 | 11 | */ 12 | class Sprint 13 | { 14 | 15 | /** 16 | * @var integer 17 | */ 18 | protected $id; 19 | 20 | /** 21 | * @var integer 22 | */ 23 | protected $status; 24 | 25 | /** 26 | * @var \DateTime 27 | */ 28 | protected $createdAt; 29 | 30 | /** 31 | * @var \DateTime 32 | */ 33 | protected $expectedClosedAt; 34 | 35 | /** 36 | * @var \DateTime 37 | */ 38 | protected $effectiveClosedAt; 39 | 40 | /** 41 | * @var Collection|Issue[] 42 | */ 43 | protected $issues; 44 | 45 | public function __construct() 46 | { 47 | $this->issues = new ArrayCollection(); 48 | $this->createdAt = new \DateTime(); 49 | } 50 | 51 | /** 52 | * @return integer 53 | */ 54 | public function getId() 55 | { 56 | return $this->id; 57 | } 58 | 59 | /** 60 | * @return \DateTime 61 | */ 62 | public function getCreatedAt() 63 | { 64 | return $this->createdAt; 65 | } 66 | 67 | /** 68 | * @return \DateTime 69 | */ 70 | public function getExpectedClosedAt() 71 | { 72 | return $this->expectedClosedAt; 73 | } 74 | 75 | /** 76 | * @return \DateTime 77 | */ 78 | public function getEffectiveClosedAt() 79 | { 80 | return $this->effectiveClosedAt; 81 | } 82 | 83 | /** 84 | * @param Issue $issues 85 | */ 86 | public function addIssue(Issue $issues) 87 | { 88 | $this->issues[] = $issues; 89 | } 90 | 91 | /** 92 | * @return Collection 93 | */ 94 | public function getIssues() 95 | { 96 | return $this->issues; 97 | } 98 | 99 | public function close() 100 | { 101 | if ($this->isClosed()) { 102 | throw new SprintAlreadyClosedException(); 103 | } 104 | 105 | foreach ($this->issues as $issue) { 106 | if ($issue->isDone()) { 107 | $issue->close(); 108 | } else { 109 | $this->issues->removeElement($issue); 110 | } 111 | } 112 | 113 | $this->setEffectiveClosedAt(new \DateTime()); 114 | $this->status = SprintStatus::CLOSE; 115 | } 116 | 117 | /** 118 | * @return bool 119 | */ 120 | public function isClosed() 121 | { 122 | return SprintStatus::CLOSE === $this->getStatus(); 123 | } 124 | 125 | /** 126 | * @return string 127 | */ 128 | public function getStatus() 129 | { 130 | return $this->status; 131 | } 132 | 133 | public function setEffectiveClosedAt(\DateTime $closedAt) 134 | { 135 | $this->effectiveClosedAt = $closedAt; 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /src/Domain/Model/Sprint/SprintAlreadyClosedException.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | class SprintAlreadyClosedException extends \Exception 9 | { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/Domain/Model/Sprint/SprintNotFoundException.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | class SprintNotFoundException extends \Exception 9 | { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/Domain/Model/Sprint/SprintRepository.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | interface SprintRepository 9 | { 10 | /** 11 | * @return \Domain\Model\Sprint\Sprint 12 | * @throws SprintNotFoundException 13 | */ 14 | public function find($id); 15 | 16 | /** 17 | * @return Sprint 18 | * 19 | * @throws SprintNotFoundException 20 | * @throws \Doctrine\ORM\NonUniqueResultException 21 | */ 22 | public function findSprintToClose(); 23 | 24 | /** 25 | * @return int 26 | */ 27 | public function findAverageClosedIssues(); 28 | 29 | public function update(Sprint $sprint); 30 | } 31 | -------------------------------------------------------------------------------- /src/Domain/Model/Sprint/SprintStatus.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | final class SprintStatus 9 | { 10 | const CLOSE = 'CLOSE'; 11 | 12 | const OPEN = 'OPEN'; 13 | } 14 | -------------------------------------------------------------------------------- /src/Interfaces/Sprint/DTO/ReportDTO.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | class ReportDTO 9 | { 10 | 11 | /** 12 | * @var int 13 | */ 14 | public $sprintId; 15 | 16 | /** 17 | * @var float 18 | */ 19 | public $averageClosedIssues; 20 | 21 | /** 22 | * @var int 23 | */ 24 | public $closedIssuesCount; 25 | 26 | public function __construct(array $report) 27 | { 28 | $this->averageClosedIssues = $report['averageClosedIssues']; 29 | $this->closedIssuesCount = $report['closedIssuesCount']; 30 | $this->sprintId = $report['sprintId']; 31 | } 32 | 33 | /** 34 | * @return float 35 | */ 36 | public function getAverageClosedIssues() 37 | { 38 | return $this->averageClosedIssues; 39 | } 40 | 41 | /** 42 | * @return int 43 | */ 44 | public function getClosedIssuesCount() 45 | { 46 | return $this->closedIssuesCount; 47 | } 48 | 49 | /** 50 | * @return int 51 | */ 52 | public function getSprintId() 53 | { 54 | return $this->sprintId; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/Interfaces/Sprint/DTO/SprintDTO.php: -------------------------------------------------------------------------------- 1 | 9 | */ 10 | class SprintDTO 11 | { 12 | 13 | /** 14 | * @var integer 15 | */ 16 | public $id; 17 | 18 | /** 19 | * @var integer 20 | */ 21 | public $status; 22 | 23 | /** 24 | * @var \DateTime 25 | */ 26 | public $createdAt; 27 | 28 | /** 29 | * @var \DateTime 30 | */ 31 | public $expectedClosedAt; 32 | 33 | /** 34 | * @var \DateTime 35 | */ 36 | public $effectiveClosedAt; 37 | 38 | public function __construct(Sprint $sprint) 39 | { 40 | $this->createdAt = $sprint->getCreatedAt()->format(\DateTime::ISO8601); 41 | if (null !== $sprint->getEffectiveClosedAt()) { 42 | $this->effectiveClosedAt = $sprint->getEffectiveClosedAt()->format(\DateTime::ISO8601); 43 | } 44 | $this->expectedClosedAt = $sprint->getExpectedClosedAt()->format(\DateTime::ISO8601); 45 | $this->id = $sprint->getId(); 46 | $this->status = $sprint->getStatus(); 47 | } 48 | 49 | /** 50 | * @return \DateTime 51 | */ 52 | public function getCreatedAt() 53 | { 54 | return $this->createdAt; 55 | } 56 | 57 | /** 58 | * @return \DateTime 59 | */ 60 | public function getEffectiveClosedAt() 61 | { 62 | return $this->effectiveClosedAt; 63 | } 64 | 65 | /** 66 | * @return \DateTime 67 | */ 68 | public function getExpectedClosedAt() 69 | { 70 | return $this->expectedClosedAt; 71 | } 72 | 73 | /** 74 | * @return int 75 | */ 76 | public function getId() 77 | { 78 | return $this->id; 79 | } 80 | 81 | /** 82 | * @return int 83 | */ 84 | public function getStatus() 85 | { 86 | return $this->status; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/Interfaces/Sprint/Internal/Assembler/ReportDTOAssembler.php: -------------------------------------------------------------------------------- 1 | 9 | */ 10 | class ReportDTOAssembler 11 | { 12 | public function toDTO(array $report) 13 | { 14 | return new ReportDTO($report); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Interfaces/Sprint/Internal/Assembler/SprintDTOAssembler.php: -------------------------------------------------------------------------------- 1 | 10 | */ 11 | class SprintDTOAssembler 12 | { 13 | public function toDTO(Sprint $sprint) 14 | { 15 | return new SprintDTO($sprint); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Interfaces/Sprint/Internal/SprintServiceFacadeImpl.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | class SprintServiceFacadeImpl implements SprintServiceFacade 15 | { 16 | 17 | /** 18 | * @var SprintService 19 | */ 20 | private $sprintService; 21 | 22 | /** 23 | * @return array 24 | * @throws \Domain\Model\Sprint\SprintNotFoundException 25 | * @throws \Domain\Model\Sprint\SprintAlreadyClosedException 26 | */ 27 | public function closeSprint($id) 28 | { 29 | $report = $this->sprintService->closeSprint($id); 30 | $assembler = new ReportDTOAssembler(); 31 | 32 | return $assembler->toDTO($report); 33 | } 34 | 35 | /** 36 | * @return SprintDTO 37 | */ 38 | public function get($id) 39 | { 40 | $sprint = $this->sprintService->get($id); 41 | $assembler = new SprintDTOAssembler(); 42 | 43 | return $assembler->toDTO($sprint); 44 | } 45 | 46 | public function setSprintService(SprintService $sprintService) 47 | { 48 | $this->sprintService = $sprintService; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/Interfaces/Sprint/SprintServiceFacade.php: -------------------------------------------------------------------------------- 1 | 9 | */ 10 | interface SprintServiceFacade 11 | { 12 | /** 13 | * @return array 14 | * @throws \Domain\Model\Sprint\SprintNotFoundException 15 | * @throws \Domain\Model\Sprint\SprintAlreadyClosedException 16 | */ 17 | public function closeSprint($id); 18 | 19 | /** 20 | * @return SprintDTO 21 | * @throws \Domain\Model\Sprint\SprintNotFoundException 22 | */ 23 | public function get($id); 24 | } 25 | -------------------------------------------------------------------------------- /tests/Application/Impl/SprintServiceTest.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class SprintServiceTest extends \PHPUnit_Framework_TestCase 18 | { 19 | 20 | /** 21 | * @var SprintServiceImpl 22 | */ 23 | private $service; 24 | 25 | /** 26 | * @test 27 | * @expectedException \Domain\Model\Sprint\SprintNotFoundException 28 | */ 29 | public function NonExistingSprint_Close_ThrowException() 30 | { 31 | InMemorySprintRepository::$sprints = array(); 32 | $this->service->closeSprint(SprintStub1::ID); 33 | } 34 | 35 | /** 36 | * @test 37 | * @expectedException \Domain\Model\Sprint\SprintAlreadyClosedException 38 | */ 39 | public function AlreadyClosedSprint_Close_ThrowException() 40 | { 41 | $this->service->closeSprint(SprintStub1::ID); 42 | } 43 | 44 | /** 45 | * @test 46 | */ 47 | public function CloseSprint() 48 | { 49 | $report = $this->service->closeSprint(SprintStub2::ID); 50 | $actualSprint = InMemorySprintRepository::$sprints[SprintStub2::ID]; 51 | $this->assertEquals(SprintStub2::ID, $report['sprintId']); 52 | $this->assertEquals(1, $report['closedIssuesCount']); 53 | $this->assertEquals(1.5, $report['averageClosedIssues']); 54 | $this->assertEquals(SprintStatus::CLOSE, $actualSprint->getStatus()); 55 | $this->assertEquals(new \DateTime(Carbon::now()->toTimeString()), $actualSprint->getEffectiveClosedAt()); 56 | $this->assertCount(1, $actualSprint->getIssues()); 57 | $this->assertClosedIssue('Domain\Model\Issue\IssueStub2', $actualSprint->getIssues()->first()); 58 | } 59 | 60 | /** 61 | * @param IssueStub1|IssueStub2 $stub 62 | */ 63 | private function assertClosedIssue($stub, Issue $issue) 64 | { 65 | $this->assertEquals(new \DateTime(Carbon::now()->toTimeString()), $issue->getCreatedAt()); 66 | $this->assertEquals(new \DateTime(Carbon::now()->toTimeString()), $issue->getClosedAt()); 67 | $this->assertEquals(new \DateTime($stub::DONE_AT), $issue->getDoneAt()); 68 | $this->assertEquals($stub::ID, $issue->getId()); 69 | $this->assertEquals(SprintStatus::CLOSE, $issue->getStatus()); 70 | $this->assertEquals($stub::DESCRIPTION, $issue->getDescription()); 71 | $this->assertEquals($stub::TITLE, $issue->getTitle()); 72 | } 73 | 74 | /** 75 | * @test 76 | */ 77 | public function CloseExpectedSprint() 78 | { 79 | $id = $this->service->closeExpectedSprint(); 80 | $actualSprint = InMemorySprintRepository::$sprints[$id]; 81 | $this->assertEquals(SprintStub2::ID, $id); 82 | $this->assertTrue($actualSprint->isClosed()); 83 | $this->assertEquals(new \DateTime(Carbon::now()->toTimeString()), $actualSprint->getEffectiveClosedAt()); 84 | $this->assertCount(1, $actualSprint->getIssues()); 85 | $this->assertClosedIssue('Domain\Model\Issue\IssueStub2', $actualSprint->getIssues()->first()); 86 | } 87 | 88 | /** 89 | * @test 90 | * @expectedException \Domain\Model\Sprint\SprintNotFoundException 91 | */ 92 | public function NonExistingSprint_Get_ThrowException() 93 | { 94 | InMemorySprintRepository::$sprints = array(); 95 | $this->service->get(SprintStub1::ID); 96 | } 97 | 98 | /** 99 | * @test 100 | */ 101 | public function Get() 102 | { 103 | $sprint = $this->service->get(SprintStub1::ID); 104 | $this->assertEquals(new \DateTime(SprintStub1::CREATED_AT), $sprint->getCreatedAt()); 105 | $this->assertEquals(new \DateTime(SprintStub1::EFFECTIVE_CLOSED_AT), $sprint->getEffectiveClosedAt()); 106 | $this->assertEquals(new \DateTime(SprintStub1::EXPECTED_CLOSED_AT), $sprint->getExpectedClosedAt()); 107 | $this->assertEquals(SprintStub1::ID, $sprint->getId()); 108 | $this->assertEquals(SprintStub1::STATUS, $sprint->getStatus()); 109 | 110 | } 111 | 112 | protected function setUp() 113 | { 114 | Carbon::setTestNow(Carbon::now()); 115 | $this->service = new SprintServiceImpl(); 116 | $this->service->setSprintRepository(new InMemorySprintRepository()); 117 | InMemorySprintRepository::$sprints = array( 118 | SprintStub1::ID => new SprintStub1(), 119 | SprintStub2::ID => new SprintStub2() 120 | ); 121 | } 122 | 123 | protected function tearDown() 124 | { 125 | Carbon::setTestNow(); 126 | } 127 | 128 | } 129 | -------------------------------------------------------------------------------- /tests/Domain/Model/Issue/IssueStub1.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | class IssueStub1 extends Issue 9 | { 10 | const DESCRIPTION = 'Description 1'; 11 | 12 | const DONE_AT = null; 13 | 14 | const ID = 10; 15 | 16 | const STATUS = "OPEN"; 17 | 18 | const TITLE = 'Issue 1'; 19 | 20 | protected $description = self::DESCRIPTION; 21 | 22 | protected $id = self::ID; 23 | 24 | protected $status = self::STATUS; 25 | 26 | protected $title = self::TITLE; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /tests/Domain/Model/Issue/IssueStub2.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | class IssueStub2 extends Issue 9 | { 10 | const DESCRIPTION = 'Description 1'; 11 | 12 | const DONE_AT = '2014-02-01'; 13 | 14 | const ID = 20; 15 | 16 | const STATUS = "DONE"; 17 | 18 | const TITLE = 'Issue 2'; 19 | 20 | protected $id = self::ID; 21 | 22 | protected $status = self::STATUS; 23 | 24 | protected $description = self::DESCRIPTION; 25 | 26 | protected $title = self::TITLE; 27 | 28 | public function __construct() 29 | { 30 | parent::__construct(); 31 | $this->doneAt = new \DateTime(self::DONE_AT); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /tests/Domain/Model/Issue/IssueTest.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | class IssueTest extends \PHPUnit_Framework_TestCase 9 | { 10 | /** 11 | * @test 12 | * @expectedException \Domain\Model\Issue\IssueAlreadyClosedException 13 | */ 14 | public function AlreadyClosedIssue_Close_ThrowException() 15 | { 16 | $issue = new Issue(); 17 | $issue->close(); 18 | $issue->close(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tests/Domain/Model/Sprint/InMemorySprintRepository.php: -------------------------------------------------------------------------------- 1 | 9 | */ 10 | class InMemorySprintRepository extends SprintRepositoryDoctrine 11 | { 12 | 13 | /** 14 | * @var Sprint[] 15 | */ 16 | public static $sprints = array(); 17 | 18 | public function __construct() 19 | { 20 | self::$sprints = array(); 21 | } 22 | 23 | /** 24 | * @return \Domain\Model\Sprint\Sprint 25 | * @throws SprintNotFoundException 26 | */ 27 | public function find($id) 28 | { 29 | if (isset(self::$sprints[$id])) { 30 | return self::$sprints[$id]; 31 | } 32 | throw new SprintNotFoundException(); 33 | } 34 | 35 | /** 36 | * @return \Domain\Model\Sprint\Sprint 37 | * @throws SprintNotFoundException 38 | */ 39 | public function findSprintToClose() 40 | { 41 | foreach (self::$sprints as $sprint) { 42 | if ('CLOSE' !== $sprint->getStatus()) { 43 | return $sprint; 44 | } 45 | } 46 | throw new SprintNotFoundException(); 47 | } 48 | 49 | public function findAverageClosedIssues() 50 | { 51 | $sprintsCount = 0; 52 | $issuesCount = 0; 53 | foreach (self::$sprints as $sprint) { 54 | $sprintsCount++; 55 | $issuesCount += $sprint->getIssues()->count(); 56 | } 57 | 58 | return $sprintsCount !== 0 ? $issuesCount / $sprintsCount : 0; 59 | } 60 | 61 | public function update(Sprint $sprint) 62 | { 63 | if (!isset(self::$sprints[$sprint->getId()])) { 64 | throw new SprintNotFoundException(); 65 | } 66 | self::$sprints[$sprint->getId()] = $sprint; 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /tests/Domain/Model/Sprint/SprintStub1.php: -------------------------------------------------------------------------------- 1 | 10 | */ 11 | class SprintStub1 extends Sprint 12 | { 13 | const CREATED_AT = '2014-01-01'; 14 | 15 | const EXPECTED_CLOSED_AT = '2014-03-01'; 16 | 17 | const EFFECTIVE_CLOSED_AT = '2014-02-01'; 18 | 19 | const ID = 1; 20 | 21 | const STATUS = SprintStatus::CLOSE; 22 | 23 | protected $id = self::ID; 24 | 25 | protected $status = self::STATUS; 26 | 27 | public function __construct() 28 | { 29 | parent::__construct(); 30 | $this->createdAt = new \DateTime(self::CREATED_AT); 31 | $this->addIssue(new IssueStub1()); 32 | $this->addIssue(new IssueStub2()); 33 | $this->expectedClosedAt = new \DateTime(self::EXPECTED_CLOSED_AT); 34 | $this->effectiveClosedAt = new \DateTime(self::EFFECTIVE_CLOSED_AT); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /tests/Domain/Model/Sprint/SprintStub2.php: -------------------------------------------------------------------------------- 1 | 10 | */ 11 | class SprintStub2 extends Sprint 12 | { 13 | const EXPECTED_CLOSED_AT = '2020-01-01'; 14 | 15 | const ID = 2; 16 | 17 | const STATUS = SprintStatus::OPEN; 18 | 19 | protected $id = self::ID; 20 | 21 | protected $status = self::STATUS; 22 | 23 | public function __construct() 24 | { 25 | parent::__construct(); 26 | $this->addIssue(new IssueStub1()); 27 | $this->addIssue(new IssueStub2()); 28 | $this->expectedClosedAt = new \DateTime(self::EXPECTED_CLOSED_AT); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /tests/bootstrap.php: -------------------------------------------------------------------------------- 1 | add('', __DIR__ . ''); 7 | -------------------------------------------------------------------------------- /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 | 9 | RewriteEngine On 10 | 11 | # Determine the RewriteBase automatically and set it as environment variable. 12 | # If you are using Apache aliases to do mass virtual hosting or installed the 13 | # project in a subdirectory, the base path will be prepended to allow proper 14 | # resolution of the app.php file and to redirect to the correct URI. It will 15 | # work in environments without path prefix as well, providing a safe, one-size 16 | # fits all solution. But as you do not need it in this case, you can comment 17 | # the following 2 lines to eliminate the overhead. 18 | RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ 19 | RewriteRule ^(.*) - [E=BASE:%1] 20 | 21 | # Sets the HTTP_AUTHORIZATION header removed by apache 22 | RewriteCond %{HTTP:Authorization} . 23 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 24 | 25 | # Redirect to URI without front controller to prevent duplicate content 26 | # (with and without `/app.php`). Only do this redirect on the initial 27 | # rewrite by Apache and not on subsequent cycles. Otherwise we would get an 28 | # endless redirect loop (request -> rewrite to front controller -> 29 | # redirect -> request -> ...). 30 | # So in case you get a "too many redirects" error or you always get redirected 31 | # to the start page because your Apache does not expose the REDIRECT_STATUS 32 | # environment variable, you have 2 choices: 33 | # - disable this feature by commenting the following 2 lines or 34 | # - use Apache >= 2.3.9 and replace all L flags by END flags and remove the 35 | # following RewriteCond (best solution) 36 | RewriteCond %{ENV:REDIRECT_STATUS} ^$ 37 | RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L] 38 | 39 | # If the requested filename exists, simply serve it. 40 | # We only want to let Apache serve files and not directories. 41 | RewriteCond %{REQUEST_FILENAME} -f 42 | RewriteRule .? - [L] 43 | 44 | # Rewrite all other queries to the front controller. 45 | RewriteRule .? %{ENV:BASE}/app.php [L] 46 | 47 | 48 | 49 | 50 | # When mod_rewrite is not available, we instruct a temporary redirect of 51 | # the start page to the front controller explicitly so that the website 52 | # and the generated links can still be used. 53 | RedirectMatch 302 ^/$ /app.php/ 54 | # RedirectTemp cannot be used instead 55 | 56 | 57 | -------------------------------------------------------------------------------- /web/app.php: -------------------------------------------------------------------------------- 1 | unregister(); 14 | $apcLoader->register(true); 15 | */ 16 | 17 | require_once __DIR__.'/../app/AppKernel.php'; 18 | //require_once __DIR__.'/../app/AppCache.php'; 19 | 20 | $kernel = new AppKernel('prod', false); 21 | $kernel->loadClassCache(); 22 | //$kernel = new AppCache($kernel); 23 | 24 | // When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter 25 | //Request::enableHttpMethodParameterOverride(); 26 | $request = Request::createFromGlobals(); 27 | $response = $kernel->handle($request); 28 | $response->send(); 29 | $kernel->terminate($request, $response); 30 | -------------------------------------------------------------------------------- /web/app_dev.php: -------------------------------------------------------------------------------- 1 | loadClassCache(); 27 | $request = Request::createFromGlobals(); 28 | $response = $kernel->handle($request); 29 | $response->send(); 30 | $kernel->terminate($request, $response); 31 | -------------------------------------------------------------------------------- /web/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/romainkuzniak/symfony-ddd/c3b49ffef3dd7156a9f11114b928d415de063b30/web/apple-touch-icon.png -------------------------------------------------------------------------------- /web/config.php: -------------------------------------------------------------------------------- 1 | getFailedRequirements(); 20 | $minorProblems = $symfonyRequirements->getFailedRecommendations(); 21 | 22 | ?> 23 | 24 | 25 | 26 | 27 | 28 | Symfony Configuration 29 | 30 | 31 | 32 | 33 | 34 |
35 |
36 | 39 | 40 | 60 |
61 | 62 |
63 |
64 |
65 |

Welcome!

66 |

Welcome to your new Symfony project.

67 |

68 | This script will guide you through the basic configuration of your project. 69 | You can also do the same by editing the ‘app/config/parameters.yml’ file directly. 70 |

71 | 72 | 73 |

Major problems

74 |

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

75 |
    76 | 77 |
  1. getHelpHtml() ?>
  2. 78 | 79 |
80 | 81 | 82 | 83 |

Recommendations

84 |

85 | Additionally, toTo enhance your Symfony experience, 86 | it’s recommended that you fix the following: 87 |

88 |
    89 | 90 |
  1. getHelpHtml() ?>
  2. 91 | 92 |
93 | 94 | 95 | hasPhpIniConfigIssue()): ?> 96 |

* 97 | getPhpIniConfigPath()): ?> 98 | Changes to the php.ini file must be done in "getPhpIniConfigPath() ?>". 99 | 100 | To change settings, create a "php.ini". 101 | 102 |

103 | 104 | 105 | 106 |

Your configuration looks good to run Symfony.

107 | 108 | 109 | 118 |
119 |
120 |
121 |
Symfony Standard Edition
122 |
123 | 124 | 125 | -------------------------------------------------------------------------------- /web/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/romainkuzniak/symfony-ddd/c3b49ffef3dd7156a9f11114b928d415de063b30/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 | --------------------------------------------------------------------------------