PHP code example of maduser / argon-phinx

1. Go to this page and download the library: Download maduser/argon-phinx library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

maduser / argon-phinx example snippets


use Maduser\Argon\Container\AbstractServiceProvider;
use Maduser\Argon\Container\ArgonContainer;
use Maduser\Argon\Phinx\Config\PhinxConfigRegistry;
use Maduser\Argon\Phinx\Provider\PhinxServiceProvider;

final class AppServiceProvider extends AbstractServiceProvider
{
    #[\Override]
    public function register(ArgonContainer $container): void
    {
        $container->register(PhinxServiceProvider::class);
        $container->register(MigrationServiceProvider::class);
    }
}

final class MigrationServiceProvider extends AbstractServiceProvider
{
    #[\Override]
    public function register(ArgonContainer $container): void
    {
        $basePath = $container->getParameters()->get('basePath');
        assert(is_string($basePath));

        $container->get(PhinxConfigRegistry::class)
            ->addMigrationPath($basePath . '/database/migrations')
            ->addEnvironment('default', [
                'adapter' => 'sqlite',
                'name' => $basePath . '/storage/database/argon.sqlite',
                'suffix' => '',
            ])
            ->setDefaultEnvironment('default');
    }
}
bash
php bin/console phinx:status
php bin/console phinx:migrate
php bin/console phinx:rollback
php bin/console phinx:create CreateUsers