grasmash/expander
Expander is a Laravel package for managing feature rollouts and gating functionality. It helps you define “expansions” that can be enabled per environment, user, or percentage, making it easy to ship safely, run experiments, and toggle features without redeploys.
Architecture Fit
Strengths:
user.posts → hydrated relationships).UserExpander, ConfigExpander), reducing boilerplate in controllers/transformers.${env.VAR}) integrates with Laravel’s .env system, useful for dynamic configs (e.g., feature flags, API endpoints).Gaps:
Expander to Laravel’s container) or manual instantiation.with() clauses, lazy loading). This may force manual query logic in expanders.${not.real.property}) default to leaving the placeholder intact. Custom error strategies (e.g., throw exceptions, use defaults) require wrapper logic.Integration Feasibility
{"user": {"id": 1, "posts": ["expand"]}}) into hydrated objects.user.address.city.region) without recursive manual logic.fn($id) => User::with('posts')->find($id)).Technical Risk
assessment-tpm.md mentions the repo is "inaccessible" (contradicted by GitHub link). Verify CI/CD, testing coverage, and community activity (e.g., open issues/PRs).A -> B -> A). Custom logic or middleware (e.g., depth limits) may be needed.psr/log (v2+) may clash with Laravel’s logging stack (e.g., Monolog). Use NullLogger or Laravel’s Log facade.max_execution_time and memory_limit.User model vs. array). Ensure consistent return types (e.g., fn($id): array).Key Questions
Expander globally or instantiate per-request?Cache::remember) or queue workers for async resolution?with() logic or integrate with Laravel’s App\ExpandsMacro?null, or use defaults? Example: ${env.MISSING_VAR}.${user.token})?Mockery or custom factories?@include/@includeWhen (Blade), collect() transformations, or API Resources.array_walk) if the package lacks critical features.Stack Fit
Expander as a singleton or context-bound instance in AppServiceProvider:
$this->app->singleton(Expander::class, fn($app) => new Expander($app['log']));
ExpandRequestPayload).Illuminate\Http\Resources\Json\JsonResource to expand nested fields:
public function toArray($request) {
return [
'user' => Expander::expand($this->user->toArray(), ['user' => $this->user->load('posts')]),
];
}
full_name from first_name + last_name).where('status', ${request.status}))..env + DB configs: Expand config/app.php with environment variables:
$config = Expander::expandArrayProperties(config('app'), $_ENV);
Migration Path
array_merge_recursive) with expandArrayProperties.config/services.php to merge environment-specific overrides.User, Post, etc., in a dedicated ExpanderService.PATCH /posts with nested author references).Cache::remember('user:1', 10, fn() => User::find(1))).AppServiceProviders, FormRequests) with expanders.deprecated() helper.Compatibility
grasmash/expander:^2.0.Log facade or NullLogger:
$expander->setLogger(app(Log::class));
implode() may not suit all cases (e.g., JSON arrays). Extend StringifierInterface for custom formats.with() or batch loading:
$expander->addExpander('user', fn($id) => User::with('posts')->find($id));
Sequencing
config/expander.php).config/app.php with .env overrides.PUT /users with nested address references).Validator::make($expandedPayload)).How can I help you explore Laravel packages today?