Download the PHP package sebastiaanluca/laravel-conditional-providers without Composer

On this page you can find all versions of the php package sebastiaanluca/laravel-conditional-providers. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-conditional-providers

Laravel Conditional Providers

Latest stable release Build status Total downloads Total stars

Read my blog View my other packages and projects Follow @sebastiaanluca on Twitter Share this package on Twitter

Load Laravel service providers and facades based on the current environment.

Specify the service providers and facades to load per environment directly in your configuration file. No more need to add lengthy blocks of conditionals to your AppServiceProvider, do it all in the app configuration file like you would with any service provider and facade!

Inspired by Matt Staufer, Sven Luijten, and others.

Table of contents

What does it solve?

Say you're using a package like barryvdh/laravel-ide-helper in your project. If you've followed its installation instructions and require it only in development environments (like you should), you'd do the following:

And then add the service provider to your app's config providers array:

Now when you run composer install --no-dev in your production environment to install all but development packages, this will throw an exception. Laravel will try to load the registered service provider class which it can't find, because the package is not installed.

Of course you can —per the instructions— conditionally load the provider manually in the register method of the app/Providers/AppServiceProvider.php file:

But you'd have to do this for each development package and each environment you don't want it loaded in, which is hardly maintainable and pollutes your application-specific code.

Enter Laravel conditional providers to easily do all of this in your main application config file!

Requirements

How to install

How to use

Conditional providers

Disable auto-discovery of the package's service provider by adding it to your composer.json's relevant section:

Once you're set up, simply add a providers array per environment to your config/app.php file:

Each providers key is optional and can be empty —so you could just use the local_providers array or none at all.

The example above will do the following in a local environment:

All done! Now your app service provider is clean and you get a better view on what's loaded and when, with the added benefit of enabling or disabling packages based on environment.

Conditional aliases

In addition to conditionally loading providers, this workflow is also available for aliases/facades. Add a facades/aliases array per environment to your config/app.php file like so:

That's it! This will load the Debugbar facade only in the local environment.

License

This package operates under the MIT License (MIT). Please see LICENSE for more information.

Change log

Please see CHANGELOG for more information what has changed recently.

Testing

Contributing

Please see CONDUCT for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

About

My name is Sebastiaan and I'm a freelance Laravel developer specializing in building custom Laravel applications. Check out my portfolio for more information, my blog for the latest tips and tricks, and my other packages to kick-start your next project.

Have a project that could use some guidance? Send me an e-mail at [email protected]!


All versions of laravel-conditional-providers with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3
laravel/framework Version ^6.0|^7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package sebastiaanluca/laravel-conditional-providers contains the following files

Loading the files please wait ....