microweber-packages/microweber-core
Microweber Core
Deterministic service-provider loader for Microweber CMS.
Why this exists
Laravel's package auto-discovery reads vendor/composer/installed.json and
caches the result in bootstrap/cache/packages.php. Under php-fpm and
php-cgi, multiple concurrent requests can race while that cache file is
being written (truncated read, partial write, opcache serving a stale version).
This produces errors like:
Call to undefined function normalize_path()
in src/MicroweberPackages/App/functions/paths.php (line 52)
This package replaces auto-discovery with a single CoreServiceProvider that
registers every internal and third-party package provider in a fixed,
deterministic order — no cache files, no race conditions.
Installation
In the Microweber monorepo
Already wired: AppServiceProvider::register() (the single provider in
bootstrap/providers.php) registers MicroweberPackages\Core\CoreServiceProvider
as its very first statement, so every package loads before the rest of the app.
In a standalone Laravel app
composer require microweber-packages/microweber-core
Add to bootstrap/providers.php (Laravel 11+):
return [
\MicroweberPackages\Core\CoreServiceProvider::class,
// ... your other providers
];
Or for Laravel 10 and below, add to config/app.php:
'providers' => [
\MicroweberPackages\Core\CoreServiceProvider::class,
// ...
],
The provider guards every registration with class_exists(), so it's safe
to use even if not all sub-packages are installed.
How it works
dont-discover: ["*"]in the rootcomposer.jsontells Laravel to skip auto-discovery entirely.CoreServiceProvideris registered first — as the opening statement ofAppServiceProvider::register(), the app's master provider.- It registers internal Microweber packages in dependency order (filesystem helpers first, then config, database, etc.).
- It then registers third-party providers that were previously auto-discovered.
- Each registration is guarded by
class_exists()so missing optional packages don't cause errors.
Testing
# Run core package tests only
php vendor/bin/phpunit packages/microweber-core/tests/
# Or via the root phpunit.xml suite
php vendor/bin/phpunit --testsuite MicroweberCore
License
MIT
Authors
Part of Microweber, built by:
- Peter Ivanov
- Bozhidar Slaveykov
- Nikolay Rachkov
Related Packages
Powerful PHP database abstraction layer (DBAL) with many features for database s...
Laravel Serializable Closure provides an easy and secure way to serialize closur...
Cli error handling for console/command-line PHP applications.