/** * Execute the console command. * * @return mixed */ public function fire() { $databaseConfig = array(); $environment = $this->ask('What is your current environment? [Default=local] : ', 'local'); $databaseConfig['databaseHost'] = $this->ask('Enter your database host [Default=localhost] : ', 'localhost'); $databaseConfig['databaseName'] = $this->ask('Enter your database name [Default=homestead] : ', 'homestead'); $databaseConfig['databaseUsername'] = $this->ask('Enter your database username [Default=homestead] : ', 'homestead'); $databaseConfig['databasePassword'] = $this->secret('Enter your database password [Default=secret] : ') ?: 'secret'; $databaseConfig['databasePortNumber'] = $this->ask('Enter your database port number [Default=5432] : ', '5432'); $file = new \Illuminate\Filesystem\Filesystem(); $contents = <<<ENV <?php define("LARAVEL_ENV", '{$environment}'); ENV; $file->put(base_path() . '/bootstrap/env.php', $contents); $databaseConfig['environment'] = $environment; $config = View::make('command.runtime-conf', $databaseConfig); if (!$file->isDirectory(base_path() . '/app/config/propel/')) { $file->makeDirectory(base_path() . '/app/config/propel'); } $file->put(base_path() . '/app/config/propel/runtime-conf.xml', $config); $file->put(base_path() . '/app/config/propel/buildtime-conf.xml', $config); exec('vendor/bin/propel config:convert-xml --output-dir="app/config/propel" --input-dir="app/config/propel"'); $dbContent = <<<ENV <?php return array( 'default' => 'pgsql', 'connections' => array( 'pgsql' => array( 'driver' => 'pgsql', 'host' => '{$databaseConfig['databaseHost']}', 'database' => '{$databaseConfig['databaseName']}', 'username' => '{$databaseConfig['databaseUsername']}', 'password' => '{$databaseConfig['databasePassword']}', 'charset' => 'utf8', 'prefix' => '', 'schema' => 'public', ), ), ); ENV; if (!$file->isDirectory(base_path() . '/app/config/' . $environment)) { $file->makeDirectory(base_path() . '/app/config/' . $environment); } $file->put(base_path() . '/app/config/' . $environment . '/database.php', $dbContent); $this->info('You are done.'); }
public function setUp() { parent::setUp(); $databaseUrl = __DIR__ . '/../tests/studs/testing.sqlite'; $runMigrate = false; $fileSystem = new \Illuminate\Filesystem\Filesystem(); if (!$this->inMemoryDb && !$fileSystem->exists($databaseUrl)) { $fileSystem->put($databaseUrl, ''); $runMigrate = true; fwrite(STDOUT, "\r\n- Migrate \r\n"); } $this->app['config']->set('app.key', 'SomeRandomStringWith32Characters'); $this->app['config']->set('app.debug', true); $this->app['config']->set('database.default', 'sqlite'); $this->app['config']->set('database.connections.sqlite.database', $this->inMemoryDb ? ':memory:' : $databaseUrl); if ($runMigrate || $this->inMemoryDb) { $this->migrate(); $this->createSiteAndAdminUser(); } // generally it is not run during console calls, but it is ok for testing, because // system knows that site's url is localhost app('veer')->run(); $admin = \Veer\Models\UserAdmin::where('banned', 0)->first(); \Auth::loginUsingId($admin->users_id); }
/** * Build views in order to parse php files * * @param Array $viewPaths * @param String $domain * * @return Boolean status */ public function compileViews(array $viewPaths, $domain) { // Check the output directory $targetDir = $this->storagePath . DIRECTORY_SEPARATOR . $this->storageContainer; if (!file_exists($targetDir)) { $this->createDirectory($targetDir); } // Domain separation $domainDir = $targetDir . DIRECTORY_SEPARATOR . $domain; $this->clearDirectory($domainDir); $this->createDirectory($domainDir); foreach ($viewPaths as $path) { $path = $this->basePath . DIRECTORY_SEPARATOR . $path; $fs = new \Illuminate\Filesystem\Filesystem($path); $files = $fs->allFiles(realpath($path)); $compiler = new \Illuminate\View\Compilers\BladeCompiler($fs, $domainDir); foreach ($files as $file) { $filePath = $file->getRealPath(); $compiler->setPath($filePath); $contents = $compiler->compileString($fs->get($filePath)); $compiledPath = $compiler->getCompiledPath($compiler->getPath()); $fs->put($compiledPath . '.php', $contents); } } return true; }
*/ use Illuminate\Remote; use Syncer\SSH; use Syncer\Credential\SshPubkeyAuthCredential; $conn = ['name' => 'lmodev', 'host' => 'lmodev2.lmo.com', 'username' => 'vimdev', 'auth' => ['key' => '/Users/goce/.ssh/passless_key']]; $dbCred = ['db-name' => 'ncarb_demo', 'host' => 'localhost', 'username' => "root", 'password' => 'root']; /* $connection = new Remote\Connection('remote', 'lmodev2.lmo.com', 'vimdev', ['key' => $conn['auth']['key']]); $connection->run("ls -all", function ($line) { echo "printing line" . PHP_EOL; });*/ /* Dump a DB Connection */ $db = new \Syncer\Credential\DatabaseCredential($dbCred['db-name'], $dbCred['username'], $dbCred['password']); //$adapter = new \League\Flysystem\Adapter\Local('/tmp'); $temp = new \Illuminate\Filesystem\Filesystem(); $dbDumpName = "db.dump." . $db->name() . "__" . time(); $localPath = '/tmp/' . $dbDumpName; $temp->put($localPath, "test"); $temp->exists($localPath) ? print "Hell YES" : (print "NOOOOooooooo!"); //$adapter->write($dbDumpName,"test"); /* Make a remote SSH Connection $cred = new SshPubkeyAuthCredential($conn['name'],$conn['host'],$conn['username'],$conn['auth']['key']); $ssh = new SSH('default',$cred); $ssh->run('ls -all',function($line){ echo "printing line" . PHP_EOL; echo $line; }); /**/
/** * put * * Create a file a file with the specified content * * @param string $path * @param string $content * @param string $directory (optional) * @param bool $createDirIfNotExists (optional) * @return BinaryFile */ public static function put($filename, $content, $directory = self::TMP_FOLDER_NAME, $createDirIfNotExists = true) { $fileSystem = new \Illuminate\Filesystem\Filesystem(); $directory = self::resolvePath($directory); if ($createDirIfNotExists && !$fileSystem->exists($directory)) { $fileSystem->makeDirectory($directory . DIRECTORY_SEPARATOR, 0755, true, true); } $path = $directory . DIRECTORY_SEPARATOR . $filename; $fileSystem->put($path, $content); return new BinaryFile($path); }