- What is sustainable-hustle/astrel-laravel used for?
- It is a Laravel integration package for Astrel that provides Laravel-native setup, configurable defaults, and simple framework-friendly APIs for common Astrel tasks. The v1.0.2 release adds a global astrel_env() helper that shortens calls to astrel($slug, env($envKey, $default)). It is best suited to apps already using astrel() as a slug-keyed lookup layer, not as a general configuration abstraction.
- How do I install Astrel Laravel with Composer?
- Run composer require sustainable-hustle/astrel-laravel in your Laravel project. If the package exposes publishable configuration, run php artisan vendor:publish for the Astrel config after installation. Check the README and composer.json for the exact provider registration and publish tag, since the provided overview does not list those details.
- Does Astrel Laravel include a service provider and config publishing?
- The package overview advertises Laravel-native setup with service provider integration and configurable defaults for different environments. The v1.0.2 helper itself is a global function and does not add container bindings or a migration surface. Confirm the provider and publish tag in the README or package source before relying on them.
- Is astrel_env() safe to use with php artisan config:cache?
- Not automatically. Laravel's config:cache stops .env files from loading outside config/*.php, so any env() call in application code, jobs, or Blade returns the supplied default instead of the real value. If astrel_env() calls env() directly at runtime, it can silently fall back to defaults in production; restrict it to config files or confirm the package reads through the config repository.
- How does astrel_env() build the environment key from a slug?
- The one-argument form derives an env key from the slug, for example my-slug becomes MY_SLUG. The exact rules for casing, dashes, dots, and numeric segments are not documented in the provided notes, so treat the convention as an implicit API. Ask the maintainer whether those rules are stable across minor versions before depending on them.
- Which Laravel and PHP versions does Astrel Laravel support?
- The provided overview and TPM notes do not list a supported Laravel or PHP version matrix. Check the package's composer.json require constraints and CI configuration for the authoritative answer. Because v1.0.2 is an early patch release, verify compatibility in your target Laravel version before adopting it.
- Is the astrel_env() global helper guarded with function_exists?
- The context does not confirm whether astrel_env() is wrapped in a function_exists guard. A new function in the root namespace can collide with other packages or your own helpers, so inspect the source before installing it in a large codebase. If it is unguarded, consider a namespaced wrapper or avoid the helper.
- How does astrel_env() handle missing or empty environment variables?
- The helper reduces to astrel($slug, env($envKey, $default)), so env('MY_SLUG') with no default yields null when the variable is absent. That can collapse three states: variable absent, variable set to an empty string, and variable set to a falsy string. Pass explicit defaults and confirm how astrel() distinguishes unset from empty before relying on the helper.
- Can I call astrel_env() from Blade templates, jobs, or application code?
- You can call a global helper from those places, but environment resolution is the concern. With cached configuration, env() outside config files returns defaults, so calling astrel_env() in Blade, jobs, or services can produce wrong slugs or tenant values silently. Prefer resolving the value in a config file and injecting it, or call astrel() directly if that fits your design.
- Is Astrel Laravel production-ready, and what should I use instead?
- Treat it as unvetted: v1.0.2 has a small maintainer base, and the context does not confirm test coverage, license, or release cadence. If you need a configuration abstraction, standard Laravel config/*.php files with env() at the file level are the safer alternative; if you already use astrel(), direct astrel() calls work. Pin the version and test under config:cache before production.