示例#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) . '/../../');
 }
示例#2
0
文件: Booter.php 项目: laradic/dev
 /** @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;
 }
示例#3
0
 /**
  * Scans the configured documentation root directory for projects and resolves them and puts them into the projects collection
  *
  * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
  */
 protected function findAndRegisterAll()
 {
     if (!$this->items->isEmpty()) {
         return;
     }
     $this->hookPoint('projects:resolve', [$this]);
     $finder = new Finder();
     $projects = $finder->in($this->getCodex()->getDocsPath())->files()->name('config.php')->depth('<= 1')->followLinks();
     foreach ($projects as $projectDir) {
         /** @var \SplFileInfo $projectDir */
         $name = Path::getDirectoryName($projectDir->getPath());
         $config = $this->getContainer()->make('fs')->getRequire($projectDir->getRealPath());
         $config = array_replace_recursive($this->getCodex()->config('default_project_config'), $config);
         /** @var \Codex\Projects\Project $project */
         $project = $this->getContainer()->make('codex.project', ['projects' => $this, 'name' => $name, 'config' => $config]);
         // This hook allows us to exclude projects from resolving, or do some other stuff
         $hook = $this->hookPoint('projects:resolving', [$project]);
         if ($hook === false) {
             continue;
         }
         $this->items->put($name, $project);
     }
     $this->hookPoint('projects:resolved', [$this]);
 }
示例#4
0
 /**
  * @dataProvider provideIsBasePathTests
  */
 public function testIsBasePath($path, $ofPath, $result)
 {
     $this->assertSame($result, Path::isBasePath($path, $ofPath));
 }
示例#5
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;
 }
示例#6
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;
 }