Use the LaravelEnvProviders extension package to load the corresponding service provider based on the application development environment

Source: Internet
Author: User
Use the LaravelEnvProviders extension package to load corresponding service providers based on the application development environment. 1. Introduction

Laravel EnvProviders provides a new way for us to manage the loading of Service providers in Laravel applications. With this extension package, we can load specific Service providers in different development environments.

2. Installation

Install with Composer:

Composer require sven/env-providers

Then register the service provider EnvServiceProvider in config/app. php:

// Config/app. php 'Providers '=> [... Sven \ EnvProviders \ EnvServiceProvider: class,];
3. use

You must publish the configuration file of the extension package before use:

Php artisan vendor: publish -- provider = "Sven \ EnvProviders \ EnvServiceProvider"

This command releases the configuration file providers. php in the extension package to the config Directory of the application root directory. In this configuration file, we can see two arrays: load and development_environments.

There are two nested arrays in the load array: providers and aliases. this is the same as in config/app. php. you can register a service provider in providers and register a facade in aliases.

Some default values have been set in development_enviroments. you can modify them as needed. The value must match APP_ENV in. env. then, the application loads the service provider defined in load according to the current development environment set in. env.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.