Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 35 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,35 @@ Documentation is available at: https://docs.dotkernel.org/api-documentation/

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:

git clone https://github.com/dotkernel/api.git .
```shell
git clone https://github.com/dotkernel/api.git .
```

## Step 2: Install project's dependencies

composer install
```shell
composer install
```

## Step 3: Development mode

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

composer development-enable
```shell
composer development-enable
```

You can disable development mode by running:

composer development-disable
```shell
composer development-disable
```

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

composer development-status
```shell
composer development-status
```

## Step 4: Prepare config files

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

php vendor/bin/doctrine-migrations migrate
```shell
php vendor/bin/doctrine-migrations migrate
```

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

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]:
> 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]:

Hit `Enter` to confirm the operation.

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

To list all the fixtures, run:

php bin/doctrine fixtures:list
```shell
php bin/doctrine fixtures:list
```

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

To execute all fixtures, run:

php bin/doctrine fixtures:execute
```shell
php bin/doctrine fixtures:execute
```

To execute a specific fixture, run:

php bin/doctrine fixtures:execute --class=FixtureClassName
```shell
php bin/doctrine fixtures:execute --class=FixtureClassName
```

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

## Step 6: Test the installation

php -S 0.0.0.0:8080 -t public
```shell
php -S 0.0.0.0:8080 -t public
```

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

{
```text
{
"message": "DotKernel API version 5"
}
}
```

## Documentation

Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@
"Api\\Admin\\": "src/Admin/src/",
"Api\\App\\": "src/App/src/",
"Api\\User\\": "src/User/src/",
"Api\\Fixtures\\": "data/doctrine/fixtures/"
"Core\\Admin\\": "src/Core/src/Admin/src/",
"Core\\App\\": "src/Core/src/App/src/",
"Core\\User\\": "src/Core/src/User/src/"
}
},
"autoload-dev": {
Expand All @@ -109,7 +111,6 @@
"development-disable": "laminas-development-mode disable",
"development-enable": "laminas-development-mode enable",
"development-status": "laminas-development-mode status",
"mezzio": "mezzio --ansi",
"check": [
"@cs-check",
"@test",
Expand All @@ -120,7 +121,6 @@
"cs-fix": "phpcbf",
"serve": "php -S 0.0.0.0:8080 -t public/",
"static-analysis": "phpstan analyse --memory-limit 1G",
"test": "phpunit --colors=always",
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml"
"test": "phpunit --colors=always"
}
}
4 changes: 2 additions & 2 deletions config/autoload/authorization.global.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

declare(strict_types=1);

use Api\Admin\Entity\AdminRole;
use Api\User\Entity\UserRole;
use Core\Admin\Entity\AdminRole;
use Core\User\Entity\UserRole;

return [
/**
Expand Down
16 changes: 8 additions & 8 deletions config/autoload/dependencies.global.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
use Api\App\Factory\OAuthScopeRepositoryFactory;
use Api\App\Factory\UserIdentityFactory;
use Api\App\Factory\UserRepositoryFactory;
use Api\App\Repository\OAuthAccessTokenRepository;
use Api\App\Repository\OAuthAuthCodeRepository;
use Api\App\Repository\OAuthClientRepository;
use Api\App\Repository\OAuthRefreshTokenRepository;
use Api\App\Repository\OAuthScopeRepository;
use Api\App\UserIdentity;
use Api\User\Repository\UserRepository;
use Core\App\Repository\OAuthAccessTokenRepository;
use Core\App\Repository\OAuthAuthCodeRepository;
use Core\App\Repository\OAuthClientRepository;
use Core\App\Repository\OAuthRefreshTokenRepository;
use Core\App\Repository\OAuthScopeRepository;
use Core\User\Repository\UserRepository;
use Core\User\UserIdentity;
use Doctrine\Migrations\Tools\Console\Command\ExecuteCommand;
use Dot\ErrorHandler\ErrorHandlerInterface;
use Dot\ErrorHandler\LogErrorHandler;
Expand All @@ -41,8 +41,8 @@
ClientRepositoryInterface::class => OAuthClientRepository::class,
RefreshTokenRepositoryInterface::class => OAuthRefreshTokenRepository::class,
ScopeRepositoryInterface::class => OAuthScopeRepository::class,
ErrorHandlerInterface::class => LogErrorHandler::class,
Mezzio\Authentication\UserInterface::class => UserIdentity::class,
ErrorHandlerInterface::class => LogErrorHandler::class,
Mezzio\Authorization\AuthorizationInterface::class => Mezzio\Authorization\Rbac\LaminasRbac::class,
UserRepositoryInterface::class => UserRepository::class,
],
Expand Down
69 changes: 0 additions & 69 deletions config/autoload/doctrine.global.php

This file was deleted.

4 changes: 2 additions & 2 deletions config/cli-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
declare(strict_types=1);

use Doctrine\Migrations\Configuration\EntityManager\ExistingEntityManager;
use Doctrine\Migrations\Configuration\Migration\PhpFile;
use Doctrine\Migrations\Configuration\Migration\ConfigurationArray;
use Doctrine\Migrations\DependencyFactory;
use Doctrine\ORM\EntityManager;

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

return DependencyFactory::fromEntityManager(
new PhpFile('config/migrations.php'),
new ConfigurationArray($container->get('config')['doctrine']['migrations']),
new ExistingEntityManager(
$container->get(EntityManager::class)
)
Expand Down
4 changes: 4 additions & 0 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ class_exists(Mezzio\Tooling\ConfigProvider::class)
Dot\Cache\ConfigProvider::class,

// Default App module config
Core\Admin\ConfigProvider::class,
Core\App\ConfigProvider::class,
Core\User\ConfigProvider::class,
Api\Admin\ConfigProvider::class,
Api\App\ConfigProvider::class,
Api\User\ConfigProvider::class,

// Load application config in a pre-defined order in such a way that local settings
// overwrite global settings. (Loaded as first to last):
// - `global.php`
Expand Down
18 changes: 0 additions & 18 deletions config/migrations.php

This file was deleted.

2 changes: 2 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
<file>src</file>
<file>test</file>

<exclude-pattern>src/Core/src/App/src/Migration/*</exclude-pattern>

<!-- Include all rules from the Laminas Coding Standard -->
<rule ref="LaminasCodingStandard">
<!-- Exclude rule -->
Expand Down
6 changes: 3 additions & 3 deletions src/Admin/src/Command/AdminCreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

namespace Api\Admin\Command;

use Api\Admin\Entity\AdminRole;
use Api\Admin\InputFilter\CreateAdminInputFilter;
use Api\Admin\Service\AdminRoleService;
use Api\Admin\Service\AdminService;
use Api\App\Exception\BadRequestException;
use Api\App\Exception\ConflictException;
use Api\App\Exception\NotFoundException;
use Api\App\Message;
use Core\Admin\Entity\AdminRole;
use Core\App\Message;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -34,7 +34,7 @@ class AdminCreateCommand extends Command

public function __construct(
protected AdminService $adminService,
protected AdminRoleService $adminRoleService
protected AdminRoleService $adminRoleService,
) {
parent::__construct(self::$defaultName);
}
Expand Down
28 changes: 4 additions & 24 deletions src/Admin/src/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,22 @@
use Api\Admin\Collection\AdminCollection;
use Api\Admin\Collection\AdminRoleCollection;
use Api\Admin\Command\AdminCreateCommand;
use Api\Admin\Entity\Admin;
use Api\Admin\Entity\AdminRole;
use Api\Admin\Factory\AdminCreateCommandFactory;
use Api\Admin\Handler\AdminAccountHandler;
use Api\Admin\Handler\AdminCollectionHandler;
use Api\Admin\Handler\AdminHandler;
use Api\Admin\Handler\AdminRoleCollectionHandler;
use Api\Admin\Handler\AdminRoleHandler;
use Api\Admin\Repository\AdminRepository;
use Api\Admin\Repository\AdminRoleRepository;
use Api\Admin\Service\AdminRoleService;
use Api\Admin\Service\AdminRoleServiceInterface;
use Api\Admin\Service\AdminService;
use Api\Admin\Service\AdminServiceInterface;
use Api\App\ConfigProvider as AppConfigProvider;
use Api\App\Factory\HandlerDelegatorFactory;
use Doctrine\ORM\Mapping\Driver\AttributeDriver;
use Core\Admin\Entity\Admin;
use Core\Admin\Entity\AdminRole;
use Core\Admin\Repository\AdminRepository;
use Core\Admin\Repository\AdminRoleRepository;
use Dot\DependencyInjection\Factory\AttributedRepositoryFactory;
use Dot\DependencyInjection\Factory\AttributedServiceFactory;
use Mezzio\Application;
Expand All @@ -35,7 +34,6 @@ public function __invoke(): array
{
return [
'dependencies' => $this->getDependencies(),
'doctrine' => $this->getDoctrineConfig(),
MetadataMap::class => $this->getHalConfig(),
];
}
Expand Down Expand Up @@ -70,24 +68,6 @@ public function getDependencies(): array
];
}

private function getDoctrineConfig(): array
{
return [
'driver' => [
'orm_default' => [
'drivers' => [
'Api\Admin\Entity' => 'AdminEntities',
],
],
'AdminEntities' => [
'class' => AttributeDriver::class,
'cache' => 'array',
'paths' => __DIR__ . '/Entity',
],
],
];
}

public function getHalConfig(): array
{
return [
Expand Down
Loading