Skip to content

Commit

Permalink
Move src/php code into the explicit architecture structure
Browse files Browse the repository at this point in the history
I could find two components, one for user management, and another one
relative to he blog.
At this point I am trying to change the minimum code possible. I will
create the ports and any other needed abstractions at a later stage.
  • Loading branch information
hgraca committed Nov 18, 2018
1 parent b28e033 commit ed86844
Show file tree
Hide file tree
Showing 72 changed files with 753 additions and 439 deletions.
1 change: 1 addition & 0 deletions .dockerignore
@@ -1,3 +1,4 @@
no-vcs
var
!var/data/blog.sqlite
.env
4 changes: 1 addition & 3 deletions .gitignore
Expand Up @@ -37,6 +37,4 @@ Makefile.custom
.php_cs.cache
###< friendsofphp/php-cs-fixer ###

###> phpunit/phpunit ###
/phpunit.xml
###< phpunit/phpunit ###
!**/.gitkeep
7 changes: 2 additions & 5 deletions .php_cs.dist
Expand Up @@ -13,12 +13,9 @@ file that was distributed with this source code.
COMMENT;

$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->exclude('config')
->exclude('var')
->exclude('public/bundles')
->exclude('public/build')
->in(['src', 'tests', 'lib', 'build/Migration', 'build/Fixture'])
->exclude('tests/_support/_generated')
->name('*.php')
;

return PhpCsFixer\Config::create()
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Expand Up @@ -59,6 +59,7 @@ box-build-dev:
docker-compose -f build/container/dev/docker-compose.yml build --force-rm app

box-build-prd:
make db-setup-guest
docker-compose -f build/container/prd/docker-compose.yml build --force-rm app

box-push-base:
Expand Down Expand Up @@ -120,13 +121,13 @@ test-acc:
- ENV='tst' ./bin/stop # Just in case some container is left over stopped, as is the case after PHPStorm runs tests
ENV='tst' ./bin/run make db-setup-guest
ENV='tst' docker-compose -f build/container/tst/docker-compose.yml up -d -t 0
php vendor/bin/codecept run acceptance
php vendor/bin/codecept run -g acceptance
ENV='tst' ./bin/stop

test-acc-ci:
- ENV='prd' ./bin/stop # Just in case some container is left over stopped, as is the case after PHPStorm runs tests
ENV='prd' docker-compose -f build/container/prd/docker-compose.yml up -d -t 0
php vendor/bin/codecept run acceptance
php vendor/bin/codecept run -g acceptance
ENV='prd' ./bin/stop

test-ci:
Expand Down
2 changes: 1 addition & 1 deletion bin/console
@@ -1,7 +1,7 @@
#!/usr/bin/env php
<?php

use Acme\App\Kernel;
use Acme\App\Infrastructure\Framework\Symfony\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Debug\Debug;
Expand Down
64 changes: 64 additions & 0 deletions build/Fixture/Doctrine/UserFixtures.php
@@ -0,0 +1,64 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Explicit Architecture POC,
* which is created on top of the Symfony Demo application.
*
* (c) Herberto Graça <herberto.graca@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Acme\App\Build\Fixture\Doctrine;

use Acme\App\Core\Component\User\Domain\Entity\User;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\Persistence\ObjectManager;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;

/**
* Defines the sample users to load in the database before a production deployment is ready.
* Execute this command to load the data.
*
* $ php bin/console doctrine:fixtures:load
*
* See https://symfony.com/doc/current/bundles/DoctrineFixturesBundle/index.html
*
* @author Herberto Graça <herberto.graca@gmail.com>
*/
class UserFixtures extends Fixture
{
/**
* @var UserPasswordEncoderInterface
*/
private $passwordEncoder;

public function __construct(UserPasswordEncoderInterface $passwordEncoder)
{
$this->passwordEncoder = $passwordEncoder;
}

/**
* {@inheritdoc}
*/
public function load(ObjectManager $manager): void
{
$tomAdmin = new User();
$tomAdmin->setFullName('Tom Doe');
$tomAdmin->setUsername('tom_admin');
$tomAdmin->setEmail('tom_admin@symfony.com');
$tomAdmin->setRoles(['ROLE_ADMIN']);
$encodedPassword = $this->passwordEncoder->encodePassword($tomAdmin, 'kitten');
$tomAdmin->setPassword($encodedPassword);
$manager->persist($tomAdmin);
// In case if fixture objects have relations to other fixtures, adds a reference
// to that object by name and later reference it to form a relation.
// See https://symfony.com/doc/current/bundles/DoctrineFixturesBundle/index.html#sharing-objects-between-fixtures
$this->addReference('tom-admin', $tomAdmin);

$manager->flush();
}
}
File renamed without changes.
4 changes: 2 additions & 2 deletions build/container/prd/app.dockerfile
Expand Up @@ -10,6 +10,7 @@ COPY ./build/container/prd/php.ini /usr/local/etc/php/php.ini
COPY ./assets /opt/app/assets
COPY ./bin /opt/app/bin
COPY ./config /opt/app/config
COPY ./lib /opt/app/lib
COPY ./public /opt/app/public
COPY ./src /opt/app/src
COPY ./templates /opt/app/templates
Expand All @@ -22,12 +23,11 @@ COPY ./package.json /opt/app
COPY ./symfony.lock /opt/app
COPY ./webpack.config.js /opt/app
COPY ./yarn.lock /opt/app
COPY ./var/data/blog.sqlite /opt/app/var/data

WORKDIR /opt/app

RUN make dep-install-prd-guest && \
mkdir -p /opt/app/var/data && \
make db-setup-guest && \
chmod -R 777 /opt/app/var && \
make dep-clearcache-guest

Expand Down
2 changes: 1 addition & 1 deletion codeception.yml
Expand Up @@ -5,7 +5,7 @@ paths:
tests: tests
output: var/acc_tests/output
data: tests/Fixture
support: tests/_support
support: tests/Framework/Acceptance
envs: tests/_envs
actor_suffix: Tester
extensions:
Expand Down
7 changes: 5 additions & 2 deletions composer.json
Expand Up @@ -56,12 +56,15 @@
},
"autoload": {
"psr-4": {
"Acme\\App\\": "src/"
"Acme\\App\\Build\\": "build/",
"Acme\\App\\": "src/",
"Acme\\PhpExtension\\": "lib/php-extension/src/"
}
},
"autoload-dev": {
"psr-4": {
"Acme\\App\\Tests\\": "tests/"
"Acme\\App\\Test\\": "tests/",
"Acme\\PhpExtension\\Test\\": "lib/php-extension/tests/"
}
},
"scripts": {
Expand Down

0 comments on commit ed86844

Please sign in to comment.