ibrand/common
A shared foundation package for iBrand Laravel applications, bundling common helpers, utilities, and reusable components that keep projects consistent. It reduces duplication across the ecosystem, giving developers a single place for everyday functions and base functionality.
composer require ibrand/common
composer show ibrand/common # confirm the version you actually got
Before writing a single line against it, open vendor/ibrand/common/composer.json and read three keys: require (which illuminate/* versions it supports), autoload.psr-4 (the real root namespace), and extra.laravel (whether a service provider/aliases are auto-discovered). If the package is not on Packagist, add it as a VCS repository instead:
"repositories": [{ "type": "vcs", "url": "https://github.com/guojiangclub/common" }]
Then walk the src/ tree in this order, which is the usual layout for a "common classes and services" package:
src/*ServiceProvider.php — what it binds, merges, publishes, and registers.src/helpers.php or a Support/ directory — global functions are the most common thing to collide.src/Traits/, src/Models/ — these are what you will actually reuse daily.src/Services/, src/Contracts/ — the injectable behaviour and its interfaces.First use case: treat this as a shared baseline library, not a framework. The realistic first win is pulling a base model / trait (common scopes, UUIDs, audit columns) or a response/service wrapper into a new app so you do not re-copy it from a sibling project. Wire it up and prove it works with one throwaway route or a tinker session:
php artisan vendor:publish --provider="Ibrand\Common\CommonServiceProvider"
php artisan tinker
>>> app(\Ibrand\Common\CommonServiceProvider::class); // resolves or throws
Because the package has essentially no community footprint (2 stars, 0 dependents), the source is the documentation. Budget an hour to read it end to end before the first commit that depends on it.
Wrap it, never sprinkle it. The highest-value pattern with a low-signal package is a thin application-level adapter so the vendor namespace appears in exactly one place:
namespace App\Support;
use Ibrand\Common\Services\SomeService;
class SharedThings
{
public function __construct(private SomeService $inner) {}
public function doThing(array $payload): mixed
{
return $this->inner->handle($payload);
}
}
Bind it once ($this->app->bind(SharedThings::class, ...)) and your controllers/models stay vendor-agnostic. When the package rots or you fork it, you change one file.
Traits on your own classes. If src/Traits/ ships model or controller traits, use them in your own base App\Models\Model or App\Http\Controllers\Controller rather than in dozens of leaf classes — it keeps the blast radius of an upgrade to a single parent.
Explicit provider registration. Auto-discovery depends on a well-formed extra.laravel block; when in doubt, register manually in bootstrap/providers.php (Laravel 11+) or config/app.php (older) and skip the guessing.
Pin and vendor-control it.
"require": { "ibrand/common": "1.2.*" }
Commit composer.lock. If you need a patch, fork to an internal namespace (yourorg/common) via a VCS repository entry and update the PSR-4 root — that is a ten-minute job and it removes the upstream bus factor entirely.
Testing. Bind fakes at the container level and assert through your adapter, not through the vendor class:
$this->mock(SharedThings::class, fn ($m) => $m->shouldReceive('doThing')->andReturn('ok'));
Add one smoke test that simply resolves every class the provider registers — that catches broken constructor signatures immediately after a Laravel upgrade.
Config-driven behaviour. If the package merges config, read the merged result (config('...')) rather than assuming defaults, and drive environment-specific values from .env through your own config/ file.
composer.json constraints. Treat the source as a reference implementation you may end up owning.files: ["src/helpers.php"] define bare functions. If they lack if (! function_exists(...)) guards, a second package (or your own helpers) can fatal at boot with "cannot redeclare". Grep for function in the package before installing alongside another helper library.php artisan package:discover output, then php artisan config:clear && composer dump-autoload. A stale bootstrap/cache/packages.php is the usual culprit.php artisan vendor:publish --provider="..." --tag=config and diff the published file against the vendor copy; don't blindly overwrite a config name that already exists in your app.Ibrand\Common in code but ibrand\common in PSR-4, or have stray classmap entries. composer dump-autoload -o will surface it; class_exists() in tinker confirms.str_*/arr_* helpers, $app->bind string bindings, and facades removed in Laravel 9/10/11. These fail loudly at runtime, not at install — which is exactly why the resolve-everything smoke test matters.deleted_at, created_by, uuid). Read the trait's boot* methods before applying it to an existing table, and migrate the columns in the same PR.vendor/.php artisan about for provider state, php artisan tinker for app()->make() checks, and composer why ibrand/common when an unexpected transitive dependency drags it in.How can I help you explore Laravel packages today?