protected function execute(InputInterface $input, OutputInterface $output) { $basePath = Application::basePath(); chdir($basePath); $host = $input->getOption('host'); $port = $input->getOption('port'); $base = ProcessUtils::escapeArgument($basePath); $binary = ProcessUtils::escapeArgument((new PhpExecutableFinder())->find(false)); $io = new SymfonyStyle($input, $output); $io->newLine(); $io->writeln('<info>Tagmeo development server started on http://' . $host . ':' . $port . '/</info>'); $io->newLine(); passthru($binary . ' -S ' . $host . ':' . $port . ' ' . $base . '/server.php'); }
public function __construct() { $this->elixir = $this->getJson(Application::basePath('elixir.json')); add_action('wp_enqueue_scripts', function () { foreach ($this->elixir as $key => $value) { if ($key === 'assets') { foreach ($this->elixir->{$key} as $handle => $asset) { $asset->extension = $this->getExtension($asset->file); if (preg_match('/^(\\.\\/|\\.\\.\\/)(.*)$/', $asset->file, $part)) { $asset->file = home_url($part[2]); } elseif (preg_match('/^(\\/\\/|https?:\\/\\/)(.*)$/', $asset->file, $part)) { $asset->file = '//' . $part[2]; } else { $asset->file = home_url($this->getVersionedFile($asset->extension . DIRECTORY_SEPARATOR . $asset->file)); } if (!isset($asset->dependsOn)) { $asset->dependsOn = []; } if (!isset($asset->version)) { $asset->version = null; } if (!isset($asset->inFooter)) { $asset->inFooter = true; } if (!isset($asset->media)) { $asset->media = 'all'; } switch ($asset->extension) { case 'css': wp_register_style($handle, $asset->file, $asset->dependsOn, $asset->version, $asset->media); wp_enqueue_style($handle); break; case 'js': wp_register_script($handle, $asset->file, $asset->dependsOn, $asset->version, $asset->inFooter); wp_enqueue_script($handle); break; } } } } }, 100); }
public function install() { $env = $this->command->output->choice('What is the application environment?', ['development', 'staging', 'production'], 'development'); $siteUrl = $this->command->output->ask('What is the website address?', 'http://tagmeo.dev', function ($url) { $url = rtrim(preg_replace('/^(https?:\\/\\/)(.*)$/', '$1$2', $url), '/'); if (preg_match('/^https?:\\/\\//', $url)) { return $url; } return 'http://' . $url; }); $dbHost = $this->command->output->ask('What is the database host?', 'localhost'); $dbName = $this->command->output->ask('What is the database name?', 'tagmeo'); $dbUser = $this->command->output->ask('What is the database user?', 'root'); $dbPass = $this->command->output->askHidden('What is the database user password?'); $dbPrefix = $this->command->output->ask('What is the database table prefix?', 'wp_'); $dbCharset = $this->command->output->ask('What is the database character set?', 'utf8'); $dbCollation = $this->command->output->ask('What is the database collation?', 'utf8_unicode_ci'); $disableUpdater = $this->command->output->choice('Disable the automatic updater?', ['yes', 'no'], 'yes'); $disableCronjob = $this->command->output->choice('Disable the WordPress cronjob?', ['yes', 'no'], 'yes'); $disableFileEditing = $this->command->output->choice('Disable file editing in the backend?', ['yes', 'no'], 'yes'); $envFile = Application::environmentFile(); if ($this->file->exists($envFile)) { $this->command->output->warning('You are about to overwrite the existing .env file!'); if (!$this->command->output->confirm('Would you like to continue?', true)) { return; } } $vagrantFile = Application::basePath('Vagrantfile'); if ($this->file->exists($vagrantFile)) { $data = $this->file->get($vagrantFile); $data = preg_replace('/mysql_root_password = "******"/', 'mysql_root_password = "******"', $data); $fqdn = preg_replace('/^(https?:\\/\\/)(.*)$/', '$2', $siteUrl); $data = preg_replace('/hostname = "(.*)"/', 'hostname = "' . $fqdn . '"', $data); $this->file->put($vagrantFile, $data); } $disableUpdater = $disableUpdater === 'yes' ? 'true' : 'false'; $disableCronjob = $disableCronjob === 'yes' ? 'true' : 'false'; $disableFileEditing = $disableFileEditing === 'yes' ? 'true' : 'false'; $data = ['WP_ENV=' . $env . PHP_EOL, 'WP_HOME=' . $siteUrl . PHP_EOL, 'WP_SITEURL=' . $siteUrl . '/cms' . PHP_EOL, 'DB_HOST=' . $dbHost . PHP_EOL, 'DB_NAME=' . $dbName . PHP_EOL, 'DB_USER='******'DB_PASS='******'DB_PREFIX=' . $dbPrefix . PHP_EOL, 'DB_CHARSET=' . $dbCharset . PHP_EOL, 'DB_COLLATE=' . $dbCollation . PHP_EOL, 'DISABLE_CRON=' . $disableUpdater . PHP_EOL, 'DISABLE_FILE_EDIT=' . $disableCronjob . PHP_EOL, 'DISABLE_UPDATER=' . $disableFileEditing . PHP_EOL]; $this->file->put($envFile, $data); }