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

Phpspec Laravel Laravel Package

benconstable/phpspec-laravel

phpspec-laravel adds Laravel-aware testing to phpspec, bootstrapping your app and providing matchers and helpers for Eloquent models, routes, views, and more so you can write expressive specs for Laravel code.

View on GitHub
Deep Wiki
Context7

Getting Started

  • Require the package with Composer, pinning to the patched release: composer require vendor/package:^4.0.1. Version 4.0.1 fixes a broken vendor path introduced by the switch to PSR-4 autoloading, so avoid 4.0.0 in new installs and CI.
  • Laravel package auto-discovery should register the service provider automatically. If it does not, register it manually in config/app.php (Laravel 10 and below) or bootstrap/providers.php (Laravel 11+).
  • Publish only what you need: php artisan vendor:publish --provider="Vendor\Package\PackageServiceProvider". Check the package README for specific tags such as --tag=config or --tag=migrations.
  • After install or upgrade, run composer dump-autoload and clear caches: php artisan config:clear && php artisan cache:clear && php artisan package:discover.
  • First use case: resolve the package’s main manager/service from the container, or use its facade in a controller, then call the primary API. Start by reviewing the published config file for driver, credential, and path defaults.

Implementation Patterns

  • Prefer constructor injection of the package’s contract or manager in application services. Use facades in controllers, Blade templates, and small scripts for brevity.
  • If the package exposes contracts, bind your preferred implementation in AppServiceProvider using $this->app->bind() or $this->app->singleton(). This keeps package usage swappable and testable.
  • Wrap package calls behind a small application-level adapter when the integration is central to your domain. This isolates upgrades and makes it easier to fake behavior in tests.
  • Use package-provided testing fakes or helpers where available. Otherwise, mock the underlying contract in feature tests rather than hitting external services.
  • Keep configuration environment-driven. Reference env() only inside config files, then use config('package.key') throughout application code.
  • For queued jobs and long-running workers, reset or refresh any package state between jobs if the package caches configuration or connections.
  • Prefer package extension points—custom drivers, formatters, middleware, or event listeners—over subclassing internals or editing vendor files.
  • When the package dispatches events, listen for them instead of overriding the emitting service. This is usually the most upgrade-safe integration path.

Gotchas and Tips

  • Version 4.0.1 specifically fixes a broken vendor path after the PSR-4 autoloading switch. If you are on 4.0.0, upgrade immediately and run composer dump-autoload -o. If you still see path errors or “class not found,” remove vendor/composer/autoload_* and reinstall dependencies.
  • The v4 major release likely changed namespaces or autoload mapping. When upgrading from v3, update use statements and remove any hard-coded vendor paths in your code or deployment scripts.
  • Config caching can hide newly introduced config keys after an upgrade. Re-publish or merge the package config, then run php artisan config:cache.
  • Auto-discovery can fail silently when caches are stale. Run php artisan package:discover and inspect bootstrap/cache/packages.php if the provider is missing.
  • Do not edit files inside vendor/. The PSR-4 path fix means overrides should go through published config, container bindings, or documented extension points.
  • PSR-4 autoloading is case-sensitive on Linux and in CI. Verify namespace and directory casing if a class resolves locally but fails in CI.
  • Pin ^4.0.1 in composer.json to avoid reintroducing the 4.0.0 path bug. Use composer update vendor/package --with-dependencies when moving existing projects onto the patch release.
  • If the package previously relied on classmap or files autoloading, check for references to old paths in custom scripts, deployment tooling, and cached bootstrap files.
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.
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings
coleus/apps
seampact/laravel
emmyconceptng/laravel-ng-postcode
jjsquady/round-robin