Skip to content
Open
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
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
# orm-bundle
[Cycle ORM](https://github.com/cycle/orm) integration bundle for MakiseCo Framework

## Usage
`ORMProvider` should be added to app provider.
## Installation
* Register [ORMProvider](src/ORMProvider.php)
* Register [commands](src/Console/Commands)

## Available commands
* `make:migration` - Create new migration
* `migrate` - Run database migrations
* `migrate:replay` - Replay (down, up) one or multiple migrations
* `migrate:rollback` - Rollback one (default) or multiple migrations
* `migrate:status` - Get list of all available migrations and their statuses

## Configuration

Create new `database.php` config file in config folder:
```php
Expand Down
70 changes: 38 additions & 32 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,41 @@
{
"name": "makise-co/orm-bundle",
"description": "Cycle ORM integration with MakiseCo Framework",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Dmitry K.",
"email": "coder1994@gmail.com"
"name": "makise-co/orm-bundle",
"description": "Cycle ORM integration with MakiseCo Framework",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Dmitry K.",
"email": "coder1994@gmail.com"
}
],
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"preferred-install": "dist",
"sort-packages": true
},
"require": {
"php": "^7.4",
"makise-co/framework": "~2.0.0",
"makise-co/postgres-spiral-driver": "^1.0",
"cycle/orm": "^1.2",
"cycle/annotated": "^2.0",
"cycle/migrations": "^1.0",
"cycle/proxy-factory": "^1.2"
},
"require-dev": {
"phpunit/phpunit": "^9.0",
"swoole/ide-helper": "^4.5"
},
"autoload": {
"psr-4": {
"MakiseCo\\ORM\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"MakiseCo\\ORM\\Tests\\": "tests/"
}
}
],
"require": {
"php": "^7.4",
"makise-co/framework": "^1.0",
"makise-co/postgres-spiral-driver": "^1.0",
"cycle/orm": "^1.2",
"cycle/annotated": "^2.0",
"cycle/migrations": "^1.0",
"cycle/proxy-factory": "^1.2"
},
"require-dev": {
"phpunit/phpunit": "~8.0",
"swoole/ide-helper": "^4.5"
},
"autoload": {
"psr-4": {
"MakiseCo\\ORM\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"MakiseCo\\ORM\\Tests\\": "tests/"
}
}
}
28 changes: 28 additions & 0 deletions config/app.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/**
* This file is part of the Makise-Co Framework
*
* World line: 0.571024a
* (c) Dmitry K. <coder1994@gmail.com>
*/

declare(strict_types=1);

return [
'name' => 'makise-co',

'providers' => [
\MakiseCo\Log\LoggerServiceProvider::class,
\MakiseCo\Event\EventDispatcherServiceProvider::class,
\MakiseCo\Console\ConsoleServiceProvider::class,
\MakiseCo\ORM\ORMProvider::class,
],

'commands' => [
\MakiseCo\ORM\Console\Commands\MakeCommand::class,
\MakiseCo\ORM\Console\Commands\MigrateCommand::class,
\MakiseCo\ORM\Console\Commands\ReplayCommand::class,
\MakiseCo\ORM\Console\Commands\RollbackCommand::class,
\MakiseCo\ORM\Console\Commands\StatusCommand::class,
],
];
24 changes: 24 additions & 0 deletions config/logging.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/**
* This file is part of the Makise-Co Framework
*
* World line: 0.571024a
* (c) Dmitry K. <coder1994@gmail.com>
*/

declare(strict_types=1);

use function MakiseCo\Env\env;

return [
[
'handler' => \MakiseCo\Log\Handler\StreamHandler::class,
'formatter' => \MakiseCo\Log\Formatter\JsonFormatter::class,
// parameters passed to the handler constructor
'handler_with' => [
'stream' => env('LOG_CHANNEL', 'php://stdout'),
],
// parameters passed to the formatter constructor
'formatter_with' => [],
],
];
24 changes: 18 additions & 6 deletions src/Console/Commands/AbstractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,28 @@

namespace MakiseCo\ORM\Console\Commands;

use MakiseCo\ApplicationInterface;
use MakiseCo\Console\Commands\AbstractCommand as BaseAbstractCommand;
use Spiral\Migrations\Config\MigrationConfig;
use Spiral\Migrations\Migrator;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ConfirmationQuestion;

abstract class AbstractCommand extends BaseAbstractCommand
{
protected ?Migrator $migrator = null;
protected Migrator $migrator;
protected MigrationConfig $config;

protected ?MigrationConfig $config = null;

public function __construct(ApplicationInterface $app, Migrator $migrator)
protected function initialize(InputInterface $input, OutputInterface $output): void
{
$migrator = $this->makise->getContainer()->get(Migrator::class);

$this->migrator = $migrator;
$this->config = $migrator->getConfig();

parent::__construct($app);
parent::initialize($input, $output);
}

/**
Expand Down Expand Up @@ -87,4 +89,14 @@ protected function askConfirmation(): bool
new ConfirmationQuestion('<question>Would you like to continue?</question> ')
);
}

/**
* @inheritDoc
* @return null[]
*/
public function getServices(): array
{
// no any services should be loaded
return [null];
}
}
23 changes: 0 additions & 23 deletions src/Console/Commands/InitCommand.php

This file was deleted.

44 changes: 0 additions & 44 deletions src/Http/CleanOrmHeapMiddleware.php

This file was deleted.

Loading