/**
  * Setup the seeds.
  *
  * @param \Illuminate\Contracts\Foundation\Application $app
  *
  * @return void
  */
 protected function setupSeeds(Application $app)
 {
     $source = realpath(__DIR__ . '/../database/seeds/');
     if ($app instanceof LaravelApplication && $app->runningInConsole()) {
         $this->publishes([$source => database_path('seeds')], 'seeds');
     }
 }
Example #2
0
 /**
  * Determine if the app is running in the console.
  *
  * To allow testing this will return false the environment is testing.
  *
  * @return bool
  */
 public function isRunningInConsole()
 {
     if ($this->app->environment('testing')) {
         return false;
     }
     return $this->app->runningInConsole();
 }
 /**
  * Register the application service providers.
  *
  * @param  array  $providers
  * @return void
  */
 public function load(array $providers)
 {
     $manifest = $this->loadManifest();
     // First we will load the service manifest, which contains information on all
     // service providers registered with the application and which services it
     // provides. This is used to know which services are "deferred" loaders.
     if ($this->shouldRecompile($manifest, $providers)) {
         $manifest = $this->compileManifest($providers);
     }
     // If the application is running in the console, we will not lazy load any of
     // the service providers. This is mainly because it's not as necessary for
     // performance and also so any provided Artisan commands get registered.
     if ($this->app->runningInConsole()) {
         $manifest['eager'] = $manifest['providers'];
     }
     // Next, we will register events to load the providers for each of the events
     // that it has requested. This allows the service provider to defer itself
     // while still getting automatically loaded when a certain event occurs.
     foreach ($manifest['when'] as $provider => $events) {
         $this->registerLoadEvents($provider, $events);
     }
     // We will go ahead and register all of the eagerly loaded providers with the
     // application so their services can be registered with the application as
     // a provided service. Then we will set the deferred service list on it.
     foreach ($manifest['eager'] as $provider) {
         $this->app->register($this->createProvider($provider));
     }
     $this->app->setDeferredServices($manifest['deferred']);
 }
 /**
  * Handle an uncaught exception from the application.
  *
  * Note: Most exceptions can be handled via the try / catch block in
  * the HTTP and Console kernels. But, fatal error exceptions must
  * be handled differently since they are not normal exceptions.
  *
  * @param  \Exception  $e
  * @return void
  */
 public function handleException($e)
 {
     $this->getExceptionHandler()->report($e);
     if ($this->app->runningInConsole()) {
         $this->renderForConsole($e);
     } else {
         $this->renderHttpResponse($e);
     }
 }
 /**
  * Handle an uncaught exception from the application.
  *
  * Note: Most exceptions can be handled via the try / catch block in
  * the HTTP and Console kernels. But, fatal error exceptions must
  * be handled differently since they are not normal exceptions.
  *
  * @param  \Throwable  $e
  * @return void
  */
 public function handleException($e)
 {
     if (!$e instanceof Exception) {
         $e = new FatalThrowableError($e);
     }
     $this->getExceptionHandler()->report($e);
     if ($this->app->runningInConsole()) {
         $this->renderForConsole($e);
     } else {
         $this->renderHttpResponse($e);
     }
 }
 public function boot(Application $app)
 {
     $source = realpath(__DIR__ . '/migrations/');
     if ($app->runningInConsole()) {
         $this->publishes([$source => database_path('migrations')], 'migrations');
     }
 }
 /**
  * Setup the migrations.
  *
  * @param \Illuminate\Contracts\Foundation\Application $app
  *
  * @return void
  */
 protected function setupMigrations(Application $app)
 {
     $source = realpath(__DIR__ . '/../database/migrations/');
     if (class_exists('Illuminate\\Foundation\\Application', false) && $app->runningInConsole()) {
         $this->publishes([$source => database_path('migrations')], 'migrations');
     }
 }
Example #8
0
 /**
  * Copy migration to resources
  *
  * @param Application $app
  */
 private function initMigration(Application $app)
 {
     if ($app instanceof \Illuminate\Foundation\Application && $app->runningInConsole()) {
         $migrationPath = realpath(__DIR__ . '/../database/migrations');
         $this->publishes([$migrationPath => database_path('migrations')]);
     }
 }
Example #9
0
 /**
  * Bootstrap the given application.
  *
  * @param  \Illuminate\Contracts\Foundation\Application $app
  * @return void
  */
 public function bootstrap(Application $app)
 {
     /** @var \Illuminate\Foundation\Application $app*/
     $env = $app->environment();
     $filesystem = $this->files = new Filesystem();
     $loader = new FileLoader($filesystem, $app['path.config']);
     $config = new Repository($loader, $filesystem, $env);
     $loader->setRepository($config);
     $app->instance('config', $config);
     $configuredLoader = $app['config']->get('laradic_config.loader');
     if (isset($configuredLoader) && $configuredLoader !== 'file') {
         if ($configuredLoader === 'db') {
             $loader = new DatabaseLoader($filesystem, $app['path.config']);
             $config->setLoader($loader);
             $app->booted(function () use($app, $loader, $config) {
                 $loader->setDatabase($app['db']->connection());
                 $loader->setDatabaseTable($app['config']->get('laradic_config.loaders.db.table'));
             });
             $loader->setRepository($config);
         }
     }
     if (file_exists($cached = $app->getCachedConfigPath()) && !$app->runningInConsole()) {
         $items = (require $cached);
         $loadedFromCache = true;
     }
     if (!isset($loadedFromCache)) {
         # $this->loadConfigurationFiles($app, $config);
     }
     date_default_timezone_set($config['app.timezone']);
     mb_internal_encoding('UTF-8');
 }
Example #10
0
 /**
  * Copy migration to root project
  *
  * @param Application $app
  */
 private function initCMS(Application $app)
 {
     if ($app instanceof \Illuminate\Foundation\Application && $app->runningInConsole()) {
         $migrationPath = realpath(__DIR__ . '/migration');
         (new Filesystem())->makeDirectory(app_path('Models'), 0755, false, true);
         $this->publishes([$migrationPath => database_path('migrations'), __DIR__ . "/module" => app_path('Http/Modules'), __DIR__ . "/resource" => resource_path(), __DIR__ . "/gulp" => base_path(), __DIR__ . "/configs" => config_path('cms')]);
     }
 }
Example #11
0
 /**
  * Setup the config.
  *
  * @param \Illuminate\Contracts\Foundation\Application $app
  *
  * @return void
  */
 protected function setupConfig(Application $app)
 {
     $source = realpath(__DIR___ . '/../config/gitlib.php');
     if ($app instanceof LaravelApplication && $app->runningInConsole()) {
         $this->publishes([$source => config_path('gitlib.php')]);
     } elseif ($app instanceof LumanApplication) {
         $app->configure('gitlib');
     }
     $this->mergeConfigFrom($source, 'gitlib');
 }
 /**
  * Setup the config.
  *
  * @param \Illuminate\Contracts\Foundation\Application $app
  *
  * @return void
  */
 protected function setupConfig(Application $app)
 {
     $source = realpath(__DIR__ . '/../config/pusher.php');
     if (class_exists('Illuminate\\Foundation\\Application', false) && $app->runningInConsole()) {
         $this->publishes([$source => config_path('pusher.php')]);
     } elseif (class_exists('Laravel\\Lumen\\Application', false)) {
         $app->configure('pusher');
     }
     $this->mergeConfigFrom($source, 'pusher');
 }
 /**
  * Setup the config.
  *
  * @param \Illuminate\Contracts\Foundation\Application $app
  *
  * @return void
  */
 protected function setupConfig(Application $app)
 {
     $source = __DIR__ . '/config/telegram.php';
     if ($app instanceof LaravelApplication && $app->runningInConsole()) {
         $this->publishes([$source => config_path('telegram.php')]);
     } elseif ($app instanceof LumenApplication) {
         $app->configure('telegram');
     }
     $this->mergeConfigFrom($source, 'telegram');
 }
Example #14
0
 protected function error(\Exception $e)
 {
     global $argv;
     if ($this->app->runningInConsole() && in_array('package:publish', $argv)) {
         $command = $this->container->command();
         if ($command) {
             $command->error($e->getMessage());
         }
         return;
     }
     throw $e;
 }
 /**
  * Handle the command.
  *
  * @param Application $application
  */
 public function handle(Application $application, Laravel $laravel)
 {
     $app = env('APPLICATION_REFERENCE', 'default');
     if ($laravel->runningInConsole()) {
         $app = (new ArgvInput())->getParameterOption('--app', $app);
         $laravel->bind('path.public', function () use($laravel) {
             if ($path = env('PUBLIC_PATH')) {
                 return base_path($path);
             }
             // Check default path.
             if (file_exists($path = base_path('public/index.php'))) {
                 return dirname($path);
             }
             // Check common alternative.
             if (file_exists($path = base_path('public_html/index.php'))) {
                 return dirname($path);
             }
             return base_path('public');
         });
     }
     /**
      * Set the reference to our default first.
      * When in a dev environment and working
      * with Artisan this the same as locating.
      */
     $application->setReference($app);
     /**
      * If the application is installed
      * then locate the application and
      * initialize.
      */
     if ($application->isInstalled()) {
         if (env('DB_DRIVER')) {
             $application->locate();
             $application->setup();
         }
         return;
     }
     /**
      * If we're not installed just
      * assume default for now.
      */
     $application->setReference('default');
 }