Skip to content

Commit 217831d

Browse files
authored
Merge pull request #358 from dotkernel/issue-330
Issue #330: Move common logic to `Core` module
2 parents 8473303 + e8818be commit 217831d

File tree

126 files changed

+636
-549
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+636
-549
lines changed

README.md

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,35 @@ Documentation is available at: https://docs.dotkernel.org/api-documentation/
3131

3232
Using your terminal, navigate inside the directory you want to download the project files into. Make sure that the directory is empty before proceeding to the download process. Once there, run the following command:
3333

34-
git clone https://github.com/dotkernel/api.git .
34+
```shell
35+
git clone https://github.com/dotkernel/api.git .
36+
```
3537

3638
## Step 2: Install project's dependencies
3739

38-
composer install
40+
```shell
41+
composer install
42+
```
3943

4044
## Step 3: Development mode
4145

4246
If you're installing the project for development, make sure you have development mode enabled, by running:
4347

44-
composer development-enable
48+
```shell
49+
composer development-enable
50+
```
4551

4652
You can disable development mode by running:
4753

48-
composer development-disable
54+
```shell
55+
composer development-disable
56+
```
4957

5058
You can check if you have development mode enabled by running:
5159

52-
composer development-status
60+
```shell
61+
composer development-status
62+
```
5363

5464
## Step 4: Prepare config files
5565

@@ -66,11 +76,13 @@ You can check if you have development mode enabled by running:
6676
* fill out the database connection params in `config/autoload/local.php` under `$databases['default']`
6777
* run the database migrations by using the following command:
6878

69-
php vendor/bin/doctrine-migrations migrate
79+
```shell
80+
php vendor/bin/doctrine-migrations migrate
81+
```
7082

7183
This command will prompt you to confirm that you want to run it:
7284

73-
WARNING! You are about to execute a migration in database "..." that could result in schema changes and data loss. Are you sure you wish to continue? (yes/no) [yes]:
85+
> WARNING! You are about to execute a migration in database "..." that could result in schema changes and data loss. Are you sure you wish to continue? (yes/no) [yes]:
7486
7587
Hit `Enter` to confirm the operation.
7688

@@ -80,29 +92,39 @@ Hit `Enter` to confirm the operation.
8092

8193
To list all the fixtures, run:
8294

83-
php bin/doctrine fixtures:list
95+
```shell
96+
php bin/doctrine fixtures:list
97+
```
8498

8599
This will output all the fixtures in the order of execution.
86100

87101
To execute all fixtures, run:
88102

89-
php bin/doctrine fixtures:execute
103+
```shell
104+
php bin/doctrine fixtures:execute
105+
```
90106

91107
To execute a specific fixture, run:
92108

93-
php bin/doctrine fixtures:execute --class=FixtureClassName
109+
```shell
110+
php bin/doctrine fixtures:execute --class=FixtureClassName
111+
```
94112

95113
More details on how fixtures work can be found here: https://github.com/dotkernel/dot-data-fixtures#creating-fixtures
96114

97115
## Step 6: Test the installation
98116

99-
php -S 0.0.0.0:8080 -t public
117+
```shell
118+
php -S 0.0.0.0:8080 -t public
119+
```
100120

101121
Sending a GET request to the [home page](http://0.0.0.0:8080/) should output the following message:
102122

103-
{
123+
```text
124+
{
104125
"message": "DotKernel API version 5"
105-
}
126+
}
127+
```
106128

107129
## Documentation
108130

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@
9393
"Api\\Admin\\": "src/Admin/src/",
9494
"Api\\App\\": "src/App/src/",
9595
"Api\\User\\": "src/User/src/",
96-
"Api\\Fixtures\\": "data/doctrine/fixtures/"
96+
"Core\\Admin\\": "src/Core/src/Admin/src/",
97+
"Core\\App\\": "src/Core/src/App/src/",
98+
"Core\\User\\": "src/Core/src/User/src/"
9799
}
98100
},
99101
"autoload-dev": {
@@ -109,7 +111,6 @@
109111
"development-disable": "laminas-development-mode disable",
110112
"development-enable": "laminas-development-mode enable",
111113
"development-status": "laminas-development-mode status",
112-
"mezzio": "mezzio --ansi",
113114
"check": [
114115
"@cs-check",
115116
"@test",
@@ -120,7 +121,6 @@
120121
"cs-fix": "phpcbf",
121122
"serve": "php -S 0.0.0.0:8080 -t public/",
122123
"static-analysis": "phpstan analyse --memory-limit 1G",
123-
"test": "phpunit --colors=always",
124-
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml"
124+
"test": "phpunit --colors=always"
125125
}
126126
}

config/autoload/authorization.global.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
declare(strict_types=1);
44

5-
use Api\Admin\Entity\AdminRole;
6-
use Api\User\Entity\UserRole;
5+
use Core\Admin\Entity\AdminRole;
6+
use Core\User\Entity\UserRole;
77

88
return [
99
/**

config/autoload/dependencies.global.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
use Api\App\Factory\OAuthScopeRepositoryFactory;
1111
use Api\App\Factory\UserIdentityFactory;
1212
use Api\App\Factory\UserRepositoryFactory;
13-
use Api\App\Repository\OAuthAccessTokenRepository;
14-
use Api\App\Repository\OAuthAuthCodeRepository;
15-
use Api\App\Repository\OAuthClientRepository;
16-
use Api\App\Repository\OAuthRefreshTokenRepository;
17-
use Api\App\Repository\OAuthScopeRepository;
18-
use Api\App\UserIdentity;
19-
use Api\User\Repository\UserRepository;
13+
use Core\App\Repository\OAuthAccessTokenRepository;
14+
use Core\App\Repository\OAuthAuthCodeRepository;
15+
use Core\App\Repository\OAuthClientRepository;
16+
use Core\App\Repository\OAuthRefreshTokenRepository;
17+
use Core\App\Repository\OAuthScopeRepository;
18+
use Core\User\Repository\UserRepository;
19+
use Core\User\UserIdentity;
2020
use Doctrine\Migrations\Tools\Console\Command\ExecuteCommand;
2121
use Dot\ErrorHandler\ErrorHandlerInterface;
2222
use Dot\ErrorHandler\LogErrorHandler;
@@ -41,8 +41,8 @@
4141
ClientRepositoryInterface::class => OAuthClientRepository::class,
4242
RefreshTokenRepositoryInterface::class => OAuthRefreshTokenRepository::class,
4343
ScopeRepositoryInterface::class => OAuthScopeRepository::class,
44-
ErrorHandlerInterface::class => LogErrorHandler::class,
4544
Mezzio\Authentication\UserInterface::class => UserIdentity::class,
45+
ErrorHandlerInterface::class => LogErrorHandler::class,
4646
Mezzio\Authorization\AuthorizationInterface::class => Mezzio\Authorization\Rbac\LaminasRbac::class,
4747
UserRepositoryInterface::class => UserRepository::class,
4848
],

config/autoload/doctrine.global.php

Lines changed: 0 additions & 69 deletions
This file was deleted.

config/cli-config.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
declare(strict_types=1);
44

55
use Doctrine\Migrations\Configuration\EntityManager\ExistingEntityManager;
6-
use Doctrine\Migrations\Configuration\Migration\PhpFile;
6+
use Doctrine\Migrations\Configuration\Migration\ConfigurationArray;
77
use Doctrine\Migrations\DependencyFactory;
88
use Doctrine\ORM\EntityManager;
99

1010
$container = require 'config/container.php';
1111

1212
return DependencyFactory::fromEntityManager(
13-
new PhpFile('config/migrations.php'),
13+
new ConfigurationArray($container->get('config')['doctrine']['migrations']),
1414
new ExistingEntityManager(
1515
$container->get(EntityManager::class)
1616
)

config/config.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,13 @@ class_exists(Mezzio\Tooling\ConfigProvider::class)
4848
Dot\Cache\ConfigProvider::class,
4949

5050
// Default App module config
51+
Core\Admin\ConfigProvider::class,
52+
Core\App\ConfigProvider::class,
53+
Core\User\ConfigProvider::class,
5154
Api\Admin\ConfigProvider::class,
5255
Api\App\ConfigProvider::class,
5356
Api\User\ConfigProvider::class,
57+
5458
// Load application config in a pre-defined order in such a way that local settings
5559
// overwrite global settings. (Loaded as first to last):
5660
// - `global.php`

config/migrations.php

Lines changed: 0 additions & 18 deletions
This file was deleted.

phpcs.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
<file>src</file>
1919
<file>test</file>
2020

21+
<exclude-pattern>src/Core/src/App/src/Migration/*</exclude-pattern>
22+
2123
<!-- Include all rules from the Laminas Coding Standard -->
2224
<rule ref="LaminasCodingStandard">
2325
<!-- Exclude rule -->

src/Admin/src/Command/AdminCreateCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
namespace Api\Admin\Command;
66

7-
use Api\Admin\Entity\AdminRole;
87
use Api\Admin\InputFilter\CreateAdminInputFilter;
98
use Api\Admin\Service\AdminRoleService;
109
use Api\Admin\Service\AdminService;
1110
use Api\App\Exception\BadRequestException;
1211
use Api\App\Exception\ConflictException;
1312
use Api\App\Exception\NotFoundException;
14-
use Api\App\Message;
13+
use Core\Admin\Entity\AdminRole;
14+
use Core\App\Message;
1515
use Symfony\Component\Console\Attribute\AsCommand;
1616
use Symfony\Component\Console\Command\Command;
1717
use Symfony\Component\Console\Input\InputInterface;
@@ -34,7 +34,7 @@ class AdminCreateCommand extends Command
3434

3535
public function __construct(
3636
protected AdminService $adminService,
37-
protected AdminRoleService $adminRoleService
37+
protected AdminRoleService $adminRoleService,
3838
) {
3939
parent::__construct(self::$defaultName);
4040
}

0 commit comments

Comments
 (0)