roots/support
General-purpose helper functions used across Roots WordPress projects. Includes Laravel-style env() lookup, value() for closures, utilities to add/remove callbacks across multiple WordPress actions/filters, and a wp_die() wrapper with Roots defaults.
Roots\env() fallback to Illuminate\Support\Env::get()), improving Laravel compatibility.Roots\env() change reduces redundancy with Laravel’s built-in env() helper.\Roots\Closure conflicts (PR #2) aligns with Laravel’s autoloading expectations.Str::, Arr::, etc. Requires granular evaluation.Roots\env()’s Laravel fallback simplifies integration.Roots\env() change is a positive step, but other helpers may still rely on WordPress globals (e.g., WPINC checks).env() and Closure fixes isolated, or are other helpers being refactored?get_template_directory())?Roots\env() fallback introduce measurable overhead?Illuminate\Support\Env::get(), requiring no additional setup.Roots\env():
// No action needed; falls back to Laravel's env() automatically.
$value = Roots\env('APP_KEY');
// app/Providers/SupportServiceProvider.php
public function boot()
{
if (!defined('WPINC')) {
Roots\Helpers::disableWordPressFeatures();
}
}
env()).get_home_url()).Roots\env() with Laravel’s env() globally.if (defined('WPINC')) {
return Roots\wordpress_specific_helper();
}
return Laravel\fallback_helper();
\Roots\Closure issues. Verify other classes follow PSR-4.Roots\env() fallback as a template for other helpers.if (class_exists('Illuminate\Support\Env')) {
return Env::get('key');
}
return Roots\env('key'); // Fallback to original (WordPress) logic.
Roots\env(): Immediate win; no risk.path(), value(), etc., in a Laravel context.Roots\get_template_directory() → base_path('templates')).Roots\path() → storage_path()).Roots\env() and Closure fixes demonstrate active maintenance, but:
Roots\env() logic shifts).Arr:: instead of Roots\array_*).Roots\env()’s Laravel fallback reduces edge cases, but other helpers may still cause issues.dd() or Xdebug to trace helper execution paths in Laravel.Roots\env() now uses Laravel’s env().Roots\get_home_url()).env()).Roots\Helpers to the container).// Avoid:
Roots\path('app');
// Prefer:
app()->make('Roots\Helpers')->path('app');
env(): Now throws clear errors if Laravel’s env() is unavailable.null or incorrect values in non-WordPress contexts.env()/Closure, but other helpers may break if WordPress changes.call_user_func()).Roots\file_put_contents()).Roots\env() is now transparent; other helpers require context.Roots\env() in all environments (CI, local, production).path(), value()) with edge cases (e.g., missing keys).Roots\env() in all configs/services.How can I help you explore Laravel packages today?