Beispiel #1
0
 public function guessConfigPath()
 {
     if (isset($this->dir) and isset($this->resourcesPath)) {
         return Path::join($this->dir, $this->resourcesPath, 'config');
     }
     $path = (new ReflectionClass($this))->getFileName();
     return realpath(dirname($path) . '/../../');
 }
Beispiel #2
0
 /** @return \Illuminate\Foundation\Application */
 public static function create($baseDir, $tempDir)
 {
     require $baseDir . '/app/bootstrap/autoload.php';
     /** @var \Illuminate\Foundation\Application $app */
     $app = (require_once $baseDir . '/app/bootstrap/app.php');
     $app->bind('path.public', function () use($baseDir) {
         return $baseDir . '/public';
     });
     $app->bind('path.base', function () use($baseDir) {
         return $baseDir;
     });
     $app->bind('path.storage', function () use($tempDir) {
         return $tempDir;
     });
     /** @var \Illuminate\Filesystem\Filesystem $fs */
     $fs = $app->make('files');
     $fs->makeDirectory($tempDir, 0777, true);
     $makedirs = ['app', 'framework/cache', 'framework/sessions', 'framework/views', 'logs'];
     foreach ($makedirs as $d) {
         $fs->makeDirectory(Path::join($tempDir, $d), 0777, true);
     }
     $dbPath = Path::join($tempDir, 'database.sqlite');
     $fs->put($dbPath, '');
     $app->config->set('cache.driver', 'file');
     $app->config->set('database.default', 'sqlite');
     $app->config->set('database.connections.sqlite', ['driver' => 'sqlite', 'database' => $dbPath, 'prefix' => '']);
     $app->config->set('mail.driver', 'log');
     $app->config->set('session.driver', 'file');
     //
     // MIGRATE
     //
     /** @var \Illuminate\Database\Migrations\Migrator $mg */
     $mg = $app->make('migrator');
     $mg->setConnection('sqlite');
     $mgr = $mg->getRepository();
     $mgr->setSource('sqlite');
     $mgr->createRepository();
     $mg->run($baseDir . '/database/migrations');
     #$app->boot();
     $kernel = $app->make('Illuminate\\Contracts\\Http\\Kernel');
     #$kernel->bootstrap();
     $response = $kernel->handle($request = Illuminate\Http\Request::capture());
     static::$tempDir = $tempDir;
     return static::$app = $app;
 }
Beispiel #3
0
 /**
  * path method
  *
  * @param null|string $path
  * @param bool $canonicalize
  *
  * @return string
  */
 public function path($path = null, $canonicalize = false)
 {
     $path = $path === null ? $this->path : Path::join($this->path, $path);
     return $canonicalize ? Path::canonicalize($path) : $path;
 }
Beispiel #4
0
 /**
  * Apply any cascades to an array of package options.
  *
  * @param  string  $env
  * @param  string  $package
  * @param  string  $group
  * @param  array   $items
  * @return array
  */
 public function cascadePackage($env, $package, $group, $items)
 {
     $file = "packages/{$package}/{$group}";
     if ($this->files->exists($path = $this->defaultPath . '/' . $file . '.php')) {
         $items = array_merge($items, $this->getRequire($path));
     } elseif ($this->files->exists($path = $this->defaultPath . '/' . $file . '.yml')) {
         $items = array_merge($items, $this->getYaml($path));
     }
     // @todo to yaml
     $path = $this->getPackagePath($env, $package, $group);
     if ($this->files->exists("{$path}.php")) {
         $items = array_merge($items, $this->getRequire("{$path}.php"));
     } elseif ($this->files->exists("{$path}.yml")) {
         $items = array_merge($items, $this->getYaml("{$path}.yml"));
     }
     $f = $this->files;
     $storPath = $this->laradicConfig['loaders.file.save_path'];
     $fileName = (string) \Stringy\Stringy::create($package)->slugify()->ensureRight('.php');
     $file = Path::join($storPath, $fileName);
     if ($f->exists($file)) {
         $my_items = $f->getRequire($file);
         $my_items = array_get($my_items, "{$env}.{$group}");
         if ($my_items) {
             $items = array_replace_recursive($items, $my_items);
         }
     }
     return $items;
 }