laravel / ideas

Issues board used for Laravel internals discussions.
939 stars 28 forks source link

Allow opting out of illuminate/support helpers for non-Laravel projects #1791

Open supriyo-biswas opened 5 years ago

supriyo-biswas commented 5 years ago

I'd like to use illuminate/database in a non-Laravel project, which has a dependency on illuminate/support. It declares some global functions that are in conflict with my project's functions such as env(), with(), e() and array_*().

My project's functions are also dissimilar to what is there in illuminate/support, so the if (function_exists('foo')) boilerplate does not help since they would prevent illuminate/* from working correctly.

I'd like to request for a way to opt-out of these support helpers. Doing so would probably involve:

<?php

define('ILLUMINATE_SUPPORT_OPTOUT', true);

require 'vendor/autoload.php'

and the following in the helpers.php file:

<?php
if (!defined(''ILLUMINATE_SUPPORT_OPTOUT')) {
// rest of the helper code
}
mfn commented 5 years ago

Also:

There are more scattered everywhere, too lazy to search.

I too think they should be removed/replaced with something "namespacy" to avoid global name clashes when integrating with legacy / 3rd party systems you can't control.

A first step was that all Arr and Str helpers have been removed.