PHP code example of mintellity / dbchanger

1. Go to this page and download the library: Download mintellity/dbchanger 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/ */

    

mintellity / dbchanger example snippets




return [
    // this are the environments where dbchanger should work on. The active environment is fetched by .env file.
    'envs' => [
        'local'
    ],
    // this is the header parameter's name
    'headerParameter' => 'ApiTestIdentifier',
    // some infos about your db connection. Make sure this user is allowed to create databases.
    'connection' => [
        'host' => env('DB_HOST_TEST', 'localhost'),
        'user' => env('DB_USERNAME_TEST', 'homestead'),
        'password' => env('DB_PASSWORD_TEST', 'secret'),
        'prefix' => 'yourDbPrefix_'
    ]
];

$routeMiddleware = [
  'db.changeable' => \Mintellity\DbChanger\DbChangerMiddleware::class,
  ...
]

Route::group(['as' => 'api.', 'prefix' => 'api', 'namespace' => 'Api', 'middleware' => ['db.changeable']], function () {
// ...
});

Route::get('buildDatabase/{databaseName}/{forceCreate?}', [
        'as' => 'apitest.buildDatabase',
        'uses' => '\Mintellity\DbChanger\DbChangerController@buildDatabase'
    ]);
sh
php artisan vendor:publish --provider="Mintellity\DbChanger\DbChangerServiceProvider"