Core package for Laravel projects providing module support, helpers, and multi-tenancy capabilities. This package is developed for use in Devanox Private Limited projects.
- PHP 8.5 or higher
- Laravel 13.x
You can install the package via Composer:
composer require devanoxltd/coreYou may publish all of the package's resources at once:
php artisan vendor:publish --tag="core"Or, you may publish each resource individually:
php artisan vendor:publish --tag="core-config"php artisan vendor:publish --tag="core-migrations"
php artisan migratephp artisan vendor:publish --tag="core-views"php artisan vendor:publish --tag="core-lang"Note on translations: This package ships its translations under the
englocale. To use them in a Laravel project whose default locale isen, setAPP_FALLBACK_LOCALE=engin your application's.envfile. You can still publish the language files and create anenversion underlang/vendor/core/to override individual strings.
php artisan vendor:publish --tag="core-assets"If you are using the multi-tenancy features of this package, you need to publish the tenancy configuration and migrations, and then run the installation command:
php artisan vendor:publish --tag="tenancy-config"
php artisan vendor:publish --tag="tenancy-migrations"
php artisan tenancy:install
php artisan migrateNext, register the tenant routes in your Laravel application's bootstrap/app.php file using the withRouting method's then callback:
use Devanox\Core\Http\Middleware\PreventAccessFromCentralDomains;
use Illuminate\Support\Facades\Route;
// ...
->withRouting(
web: __DIR__.'/../routes/web.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
then: function () {
if (file_exists(base_path('routes/tenant.php'))) {
Route::middleware([
'web',
PreventAccessFromCentralDomains::class,
])
->name('tenant.')
->group(base_path('routes/tenant.php'));
}
}
)If your host application needs to add custom relationships or logic to the Tenant or Domain models, you can create your own models extending the package's base models.
First, create your custom model extending the base model:
namespace App\Models;
use Devanox\Core\Models\Tenant as BaseTenant;
class Tenant extends BaseTenant
{
// Add custom relationships or logic here
public function users()
{
return $this->hasMany(User::class);
}
}Then, update the config/tenancy.php configuration file to use your new model:
'models' => [
'tenant' => App\Models\Tenant::class,
'domain' => Devanox\Core\Models\Domain::class,
],The devanoxltd/core package provides a rich set of tools to manage modules and multi-tenancy in your Laravel application.
php artisan module:list: List all installed modules and their status.php artisan module:enable {module?}: Enable a specific module. Use the--alloption to enable all modules.php artisan module:disable {module?}: Disable a specific module. Use the--alloption to disable all modules.php artisan module:migrate {module?}: Run migrations for a specific module or all modules.
php artisan app:clean-up: Clean up system data, caches, or logs.php artisan migrate:check: Check for any pending database migrations.php artisan devanox:license-check: Check licenses for the package.
php artisan tenancy:install: Generate tenancy base models and prepare configuration.php artisan tenant:create-database {id}: Create a database for a specific tenant.php artisan tenant {artisanCommand}: Run a specific Artisan command for a specific tenant or all tenants.
You can safely execute code under a specific tenant's context using the tenancy()->run() method. This will temporarily set the tenant, switch the database connections and other configured services, run your callback, and then completely restore the original configuration and tenant state.
use App\Models\Tenant;
$tenant = Tenant::find(1);
tenancy()->run($tenant, function ($tenant) {
// This code will run within the context of the tenant
// e.g., using the tenant's database connection
});The package registers several global helper functions for convenience:
isAppInstalled(): bool- Checks if the application has been installed (verifies the existence of thestorage/installedfile).modules(?bool $status = true): Collection- Retrieve a collection of modules. Passtruefor enabled,falsefor disabled, andnullfor all modules.tenancy(): \Devanox\Core\Support\Tenancy- Resolves the mainTenancymanager instance.tenant(): ?\Devanox\Core\Contracts\Models\Tenant- Returns the currently identifiedTenantmodel, ornullif tenancy is disabled or no tenant is resolved.
The service provider automatically registers the following middleware to the HTTP kernel:
Devanox\Core\Http\Middleware\InstallApp: Ensures the application is installed before handling requests.
If tenancy is enabled, it also prepends PreventAccessFromCentralDomains to protect tenant-specific routes from being accessed via central application domains.
The package registers its Blade components under the core:: namespace and its Livewire components natively.
You can use them in your views using the core:: prefix for blade views, or standard Livewire syntax for any bundled Livewire components.
The package provides the \Devanox\Core\Facades\Core facade, which is automatically aliased as Core via composer.json for easy access to core package functionality.
Run the package test suites with Composer:
composer testPlease see CHANGELOG for more information on what has changed recently.
Thank you for considering contributing to Core! Please review our contributing guide to get started.
Please review our security policy on how to report security vulnerabilities.
Core is proprietary software licensed under the Proprietary License.