tuxboy / sdam
There is no license information available for the latest version (1.0.5) of this package.
1.0.5
2018-10-23 08:14 UTC
Requires
- php: >=7.1.0
- doctrine/dbal: ^2.7
- fzaninotto/faker: ^1.8
- icanboogie/inflector: ^1.4
- php-di/phpdoc-reader: ^2.1
- psr/http-message: ^1.0
- vlucas/phpdotenv: ^2.4
Requires (Dev)
- phpunit/phpunit: ^7.2
- satooshi/php-coveralls: ^1.0
- symfony/var-dumper: ^4.1
README
SDAM (Simple Database Auto Migration)
Manage the database migrations for your PHP app, this library was made for your migration to be launched automatically in your application
There is a demo of use here
Installation
"require": { "tuxboy/sdam": "dev-master", }, "repositories": [ { "type": "vcs", "url": "git@github.com:tuxboy/sdam.git" } ],
OR with packagist
$ composer require tuxboy/sdam
How to use it
\SDAM\Config::current()->configure( [ \SDAM\Config::DATABASE => [ 'dbname' => 'database_name', 'user' => 'root', 'password' => '', 'host' => 'localhost', 'driver' => 'pdo_mysql', ], // OR use .env for the database config \SDAM\Config::ENV_FILE => 'path/your/.env' \SDAM\Config::ENTITY_PATH => 'App\Entity\\', \SDAM\Config::AUTO_DROP_FIELD => false, // Optional (default value is true) ] ); // Run migration engine in your app $maintainer = new Maintainer([Entity::class]); $maintainer->run(); // OR use middleware class $maintainer = new \SDAM\Middleware\MaintainerMiddleware([\App\Entity\Post::class], $config); $app->pipe($maintainer);
Middleware are constructed with these parameters
- Entities list, string[]
- $config, string[]
Usage
Create your Entity class, Post entity for example :
namespace App\Entity; /** * Post * * @storeName custom_table_name */ class Post { /** * @length 60 * @var string */ public $name; /** * @var string */ public $slug; /** * @store false * @var string */ public $tmp_property; /** * @text * @var string */ public $content; }
(You can see the list of possible annotations in the class AnnotationsName)
Just start the migration, either by a simple F5 if you have it enabled in your application (middleware) or other. The table will be created in your database.
Todo
- Manage relationship belongsToMany
- Better manage the tables that already exist when creating (Delete php warning)
- Completed the factory system.