system example

class SystemRestoreDatabaseCommand extends Command
{
    public function __construct(
        private readonly string $defaultDirectory,
        private readonly Connection $connection
    ) {
        parent::__construct();
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        system('mkdir -p ' . escapeshellarg($this->defaultDirectory));

        /** @var string $dbName */
        $dbName = $this->connection->getDatabase();
        /** @var Params&OverrideParams $params */
        $params = $this->connection->getParams();

        $path = sprintf('%s/%s_%s.sql', $this->defaultDirectory, $params['host'] ?? '', $dbName);

        $portString = '';
        if ($params['password'] ?? '') {
            $portString = '-p' . escapeshellarg($params['password']);
        }
class SystemDumpDatabaseCommand extends Command
{
    public function __construct(
        private readonly string $defaultDirectory,
        private readonly Connection $connection
    ) {
        parent::__construct();
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        system('mkdir -p ' . escapeshellarg($this->defaultDirectory));

        /** @var string $dbName */
        $dbName = $this->connection->getDatabase();
        /** @var Params&OverrideParams $params */
        $params = $this->connection->getParams();

        $path = sprintf('%s/%s_%s.sql', $this->defaultDirectory, $params['host'] ?? '', $dbName);

        $portString = '';
        if ($params['password'] ?? '') {
            $portString = '-p' . escapeshellarg($params['password']);
        }
Home | Imprint | This part of the site doesn't use cookies.