Creates an application and registers service providers found.

@return \Illuminate\Contracts\Foundation\Application
189877
public static function resolve(): Application
    {
        $app = (new self)->createApplication();

        $composerFile = getcwd().DIRECTORY_SEPARATOR.'composer.json';

        if (file_exists($composerFile)) {
            $namespace = (string) key(json_decode((string) file_get_contents($composerFile), true)['autoload']['psr-4']);

            $serviceProviders = array_values(array_filter(self::getProjectClasses(), function (string $class) use (
                $namespace
            ) {
                return substr($class, 0, strlen($namespace)) === $namespace && self::isServiceProvider($class);
            }));

            foreach ($serviceProviders as $serviceProvider) {
                $app->register($serviceProvider);
            }
        }

        return $app;
    }
782605
public function register(Application $application)
    {
        $provider = $this->getProvider();
        $config   = $this->getConfig();

        return $application->register(new $provider(), $config->process());
    }
555690
protected function registerMiddleware()
    {
        $this->app->singleton(Request::class, function ($app) {
            $middleware = new Middleware\Request(
                $app,
                $app[ExceptionHandler::class],
                $app[Router::class],
                $app[RequestValidator::class],
                $app['events']
            );

            $middleware->setMiddlewares($this->config('middleware', false));

            return $middleware;
        });

        $this->app->singleton(AuthMiddleware::class, function ($app) {
            return new Middleware\Auth($app[Router::class], $app[Auth::class]);
        });

        $this->app->singleton(RateLimit::class, function ($app) {
            return new Middleware\RateLimit($app[Router::class], $app[Handler::class]);
        });

        $this->app->singleton(PrepareController::class, function ($app) {
            return new Middleware\PrepareController($app[Router::class]);
        });
    }
1328472
protected function setUp()
    {
        $this->services['service']->register(array(
            'path' => function(Context $context){ return $context->app->path; },
            'config' => function(Context $context) { return clone $context->app->config; },
            'url' => function(Context $context){
                $urlFactory = $context->app->url;

                $baseUrl = $urlFactory->getBaseUrl();

                return $context->app->create('url.factory', array($context->route->getGroup(), $context->request ? : null, $baseUrl, $urlFactory->getFilters(), $urlFactory->getCallables()));
            },
            'redirect' => array(Redirect::class, array('self.response', 'self.url')),
            'form' => array(Form::class, array('self')),
            // thinking of deprecating the asset as service
            'asset' => function(Context $context){ return new AssetFactory($context->url, $context->app->path['public'], $context->config->get('asset', array()));}
        ));

        $this->setUpConfig();
    }
391340
protected function registerConfiguredServiceProviders()
    {
        $providers = $this->collectConfiguredServiceProviders();

        foreach ($providers as $provider) {
            $this->app->register($provider);
        }

        return $this;
    }
594311
public function register()
    {
        $this->app->singleton(Dispatcher::class, function ($app) {
            return new Dispatcher($app, function ($connection = null) use ($app) {
                return $app[QueueFactoryContract::class]->connection($connection);
            });
        });

        $this->app->alias(
            Dispatcher::class, DispatcherContract::class
        );

        $this->app->alias(
            Dispatcher::class, QueueingDispatcherContract::class
        );
    }
1055762
public function services()
    {
        $this->registry->add('db', function () {

            $config = $this->registry->make('config')->get('database');

            $default = $config['connections'][$config['default']];

            return new Db(Factory::create(array_merge($default, ['fetch' => $config['fetch']])));
        });
    }
705399
public function register()
    {
        $app = $this->app;

        // register spec path for app
        $app['path.specs'] = $app->basePath().'/resources/specs';

        // register spec repository
        $app->singleton('specs', function ($app) {
            $loader = new Repository\FileLoader($app['files'], $app['path.specs']);

            return new Repository\NamespacedRepository($loader);
        });

        // register addon environment
        $app->instance('addon', $this->addonEnvironment = new AddonEnvironment($app));
        $app->alias('addon', AddonEnvironment::class);

        // register addon generator
        $app->singleton('addon.generator', function ($app) {
            return new AddonGenerator();
        });
        $app->alias('addon.generator', AddonGenerator::class);

        // register database migrator
        $app->singleton('database.migrator', function ($app) {
            return new Migrator($app['db'], $app['config']);
        });
        $app->alias('database.migrator', Migrator::class);

        $app['events']->fire(new AddonWorldCreated($this->addonEnvironment));

        $this->registerClassResolvers();

        (new AddonRegistrar)->register($app, $this->addonEnvironment->addons());

        $app['events']->fire(new AddonRegistered($this->addonEnvironment));
    }
757882
public function register()
    {
        $this->app->singleton(Client::class, function (Application $app): Client {
            $config = $app['config']['contentful'];

            $options = new ClientOptions();
            if ($config['delivery.preview']) {
                $options->usingPreviewApi();
            }

            if ($config['delivery.defaultLocale']) {
                $options->withDefaultLocale($config['delivery.defaultLocale']);
            }

            if (\is_callable($config['delivery.options'])) {
                ($config['delivery.options'])($options, $app);
            }

            $client = new Client(
                $config['delivery.token'],
                $config['delivery.space'],
                $config['delivery.environment'],
                $options
            );
            $client->useIntegration($this);

            return $client;
        });
    }
886769
public function register_services()
    {

        // Register the Socialite Factory.
        // From: Laravel\Socialite\SocialiteServiceProvider
        $this->app->singleton('Laravel\Socialite\Contracts\Factory', function ($app) {

            return new SocialiteManager($app);
        });

        // Slap in the Eveonline Socialite Provider
        $eveonline = $this->app->make('Laravel\Socialite\Contracts\Factory');
        $eveonline->extend('eveonline',
            function ($app) use ($eveonline) {

                $config = $app['config']['services.eveonline'];

                return $eveonline->buildProvider(EveOnlineProvider::class, $config);
            }
        );

        // Register the datatables package! Thanks
        //  https://laracasts.com/discuss/channels/laravel/register-service-provider-and-facade-within-service-provider
        $this->app->register('Yajra\DataTables\DataTablesServiceProvider');
        $loader = AliasLoader::getInstance();
        $loader->alias('DataTables', 'Yajra\DataTables\Facades\DataTables');
    }
59422
protected function createApplication()
    {
        putenv('APP_ENV=' . $this->getEnv());

        $app = require $this->appPath;

        $app->make(Kernel::class)->bootstrap();

        Carbon::setTestNow(Carbon::now());

        return $app;
    }
718442
protected function registerFoundation()
    {
        $this->app['orchestra.installed'] = false;

        $this->app->singleton('orchestra.app', function (Application $app) {
            return new Foundation($app, new RouteResolver($app));
        });
    }
360843
protected function registerManager()
    {
        $this->app->bindShared('queue', function($app)
        {
            // Once we have an instance of the queue manager, we will register the various
            // resolvers for the queue connectors. These connectors are responsible for
            // creating the classes that accept queue configs and instantiate queues.
            $manager = new QueueManager($app);

            $this->registerConnectors($manager);

            return $manager;
        });

        $this->app->singleton('queue.connection', function ($app) {
            return $app['queue']->connection();
        });
    }
537092
public function register()
    {
        // If script is running CLI we don't activate this plugin
        if ($this->app->runningInConsole())
        {
            return;
        }

        // Default package configuration
        $this->mergeConfig();
        
        // Register singleton
        $this->app->singleton('active', function ($app) {
           return new Active($app['router']->current()->getName());
        });
        
        // Register Facade
        $loader = \Illuminate\Foundation\AliasLoader::getInstance();
        $loader->alias('Active', Facades\Active::class);
    }
1213680
public function register()
    {
        // Bind the Class
        $this->app->bind('helper', function () {
            return $this->app->make(Helper::class);
        });

        // Register an Alias of the Facade
        $this->app->booting(function () {
            $loader = AliasLoader::getInstance();
            $loader->alias('Helper', HelperFacade::class);
        });
    }
1125884
public function register()
    {
        $this->app->bindShared('db.factory', function($app)
        {
            return new ConnectionFactory($app);
        });

        $this->app->bindShared('db', function($app)
        {
            return new DatabaseManager($app, $app['db.factory']);
        });
    }
1009681
protected function registerAuthRepository()
    {
        $this->app->singleton(AuthRepositoryInterface::class, function (Application $app) {
            return $app->make(AuthRepository::class);
        });

        return $this;
    }