Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Options Laravel Package

code-distortion/options

A Laravel package for managing application options in one place. Define settings once, set defaults, validate and cast values, then retrieve them consistently across your app. Lightweight and easy to integrate.

View on GitHub
Deep Wiki
Context7

Getting Started

Install the package via Composer and publish any configuration if provided. Laravel’s package auto-discovery registers the service provider, so you can immediately resolve the package’s main class, facade, or trait. Start by reviewing the package’s README and config file to identify the primary API—typically a method that accepts an options array.

A simple first use case is passing a configuration array to a builder, component, or service. As of 0.6.1, you can safely include null values in that array; they are ignored instead of throwing an exception. This means you can pass dynamic options without pre-filtering:

use Vendor\Package\Facades\Package;

Package::make([
    'title'    => 'Welcome',
    'subtitle' => $subtitle, // may be null
    'color'    => $color,    // may be null
]);

Implementation Patterns

  • Dynamic option arrays – Build options from request data, model attributes, or config. Use null for optional values; the package skips them. This simplifies conditional logic and removes the need for array_filter.
  • Form and UI components – If the package provides Blade or Livewire components, bind options directly from Eloquent models. Nullable columns can be passed without extra checks.
  • Validation – Pair with Laravel validation to ensure non-null options meet your rules. Use nullable rules for options that may be null.
  • Service layer – Wrap option creation in a dedicated service or action class. The null-ignoring behaviour makes fluent chains and conditional merges safer.
  • Testing – Add a regression test that passes null options and asserts no exception is thrown. This locks in the new behaviour and documents the contract.

Gotchas and Tips

  • Null is not a default – Passing null does not set a default value; it simply omits the option. Use the null coalescing operator (??) if you need a fallback.
  • Debugging missing options – If an option seems absent, check whether it was passed as null. The package silently ignores it, so inspect the options array before handing it over.
  • Error handling – If you previously caught exceptions for null options, remove that logic. The new behaviour is more permissive and will not throw.
  • Extension points – Look for macros, custom resolvers, or config-based defaults. The package may allow overriding how options are merged or filtered.
  • Version pinning – This is a 0.x release; pin to ^0.6 and review changelogs for potential breaking changes in minor releases.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
skyraptor/chatter
edlugz/sasapay
abbasudo/artisan-route
mirvan/ippanel
ignibyte/aic-framework
glavweb/data-schema-bundle
glavweb/datagrid-bundle
tacticmedia/scim-server
uni-method/frame
neika-ai/sdk
adachsoft/php-code-style
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
adachsoft/api-version-bundle
cgv/localized-resource