laravel-helper-mocks maintained by kaiseki
Description
Mock laravel helper functions
Authors
Last update
2026/06/01 11:50
(dev-master)
License
Downloads
897
kaiseki/laravel-helper-mocks
Mock Laravel helper functions so packages that depend on them can run in non-Laravel projects.
Provides minimal global app(), resolve() and config() functions backed by a PSR-11 container
(read from the global $container), so code written against Laravel's helpers works without pulling
in the Laravel framework.
Installation
composer require kaiseki/laravel-helper-mocks
Requires PHP 8.2 or newer.
Usage
The helpers resolve services from a PSR-11 container exposed as the global $container. Assign it
once during bootstrap:
use Psr\Container\ContainerInterface;
/** @var ContainerInterface $myContainer */
global $container;
$container = $myContainer;
The mocked helpers are then available globally:
$container = app(); // the container itself
$service = app(MyService::class); // a service resolved from the container
$same = resolve(MyService::class);
$value = config('some.config.key');
app()— returns the container, or a service from it when given an id;nullif no PSR container is set.resolve()— alias ofapp().config()— reads a key throughkaiseki/config(Config::softGet()), returningnullwhen unset.
Each function is declared behind a function_exists() guard, so it yields to a real Laravel
installation if one is present.
Development
composer install
composer check # check-deps, cs-check, phpstan
License
MIT — see LICENSE.