<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jhavenz / laravel-migration-table-parser example snippets
use Jhavenz\LaravelMigrationTableParser\Facades\MigrationTableParser;
$result = MigrationTableParser::parse($file);
$optionalTable = $result->search('my_table');
$tablesFoundCollection = $result->tables();
use Jhavenz\LaravelMigrationTableParser\Facades\MigrationTableParser;
$result = MigrationTableParser::parse($file)
->setStrategies(MyCustomExtractionStrategy::class)
->setVisitors(MyCustomTableNameVisitor::class)
->parse(database_path('migrations/2021_01_01_000000_create_some_table.php'));
// Push, leaving the default strategies in place
config()->push('migration-table-parser.strategies', [MyCustomExtractionStrategy::class]);
// Override the default strategies
config()->set('migration-table-parser.strategies', [MyCustomExtractionStrategy::class]);
readonly class ParserResult
{
public function __construct(
private bool $successful,
private string $message,
private string $migrationFile,
private array $tablesFound = [],
private ?Throwable $error = null,
) {}
// ... other methods
}
readonly class ParsingStarted
{
public function __construct(
public string $migrationFile,
public Parser $parser
) {}
}
readonly class ParsingCompleted
{
public function __construct(
public ParserResult $result,
public Parser $parser
) {}
}
use Jhavenz\LaravelMigrationTableParser\Events\ParsingStarted;
Event::listen(ParsingStarted::class, function (ParsingStarted $event) {
// do stuff...
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.