Applications
Project structure
Introduction
As an application grows you might find that this flat directory structure will grow too big and become messy. This becomes especially true when a single Laravel installation contains multiple applications.
To solve this problem, projects running Qore.works Business, are structured a little differently.
Important takeaways
- Domain logic and application logic are separated. In many cases, multiple applications need to access the same domain logic.
- config, resources, routes, database & tests are placed in the root of the application.
Create a new application
Create a new application using artisan
make:application
Create new application in the project.
make:application {application} {type}Example command to create a new filament panel powered application
php artisan make:application TestApplication filamenttypes
filament Create an application structure for a Filament powered application
laravel Create an application structure for a Laravel powered application
api Create an application structure for a (Laravel) APIRegister your application
Filament and Laravel applications are registered automatically in service providers. Filament: app/Application/Admin/Providers/QorePanelServiceProvider.php. Laravel: app/Application/Website/Providers/ApplicationServiceProvider.php.
To manually register an application, you can add the application registration to a service provider.
use Illuminate\Support\ServiceProvider;
use QoreWorksBusiness\QoreAdminBase\Applications\Application;
use QoreWorksBusiness\QoreAdminBase\Facades\Qore;
class AppServiceProvider extends ServiceProvider
{
public function boot(): void
{
Qore::registerApplication(new Application('website', 'website'));
}
}Localization
Set default language for application
Default the locale is set from config('application.locale') and has default value nl. If you would like to change the language for an application, you can modify the config('application.locale'). If you rather would change it during register the application, that is also possible with:
Qore::registerApplication((new Application('website', 'website'))->locale('en'));Set default number locale for application
Default the number useLocale is set from config('application.number_locale') and has default value nl. If you would like to change the number locale for an application, you can modify the config('application.number_locale'). If you rather would change it during register the application, that is also possible with:
Qore::registerApplication((new Application('website', 'website'))->numberLocale('en'));Set default currency for application
Default the currency is set from config('application.currency') and has default value EUR. If you would like to change the currency for an application, you can modify the config('application.currency'). If you rather would change it during register the application, that is also possible with:
Qore::registerApplication((new Application('website', 'website'))->currency('USD'));Timezone
All timezones are being saved to UTC. This is best practice to maintain storage on UTC. When you would like to change the timezone on the display side, you can modify the config for that.
Set default timezone for application
Default the display timezone is set from config('application.timezone') and has default value Europe/Amsterdam. If you would like to change the timezone for an application, you can modify config('application.timezone'). If you rather would change it during register the application, that is also possible with:
Qore::registerApplication((new Application('website', 'website'))->timezoneDisplay('UTC'));Usage the application timezone
There is a Carbon Macro available for displaying the time in the correct timezone, for example:
now()->inApplicationTimezone()
User::first()->created_at->inApplicationTimezone();Project structure
The project is structured in a way to easily separate different applications while keeping the domain logic separate and reusable.
app/
Domain/
Influencer/
Actions/
ClaimInfluencer.php
CreateUserForInfluencer.php
RegisterInfluencer.php
SendInfluencerVerificationMail.php
AuthenticateLoginAttempt.php
ApproveClaim.php
RejectClaim.php
RevokeClaim.php
Models/
Influencer.php
DataObjects/
Events/
Contracts/
Repositories/
Advertiser/
Actions/
ReviewInfluencer.php
UpdateProfileDetail.php
Models/
Advertiser.php
Application/
Admin/ (Filament installation)
Pages/
Resources/
Policies/
InfluencerPolicy.php
Providers/
AdminPanelProvider.php
Console/
Api/
Console/
Http/
Controllers/
Middleware/
Policies/
InfluencerPolicy.php
Providers/
AppServiceProvider.php
Website/
Livewire/
Http/
Middleware/
Controllers/
Policies/
InfluencerPolicy.php
Providers/
AppServiceProvider.php
Actions/
config/
resources/
views/
vendor/
vendor-x/
application/
website/
components/
[feature]/
admin/
components/
shared-component.php
js/
application/
website/
admin/
css/
application/
website/
admin/
lang/
vendor/
application/
website/
nl/
auth.php
en/
auth.php
admin/
nl/
auth.php
en/
auth.php
database/
migrations/
factories/
InfluencerFactory.php
seeders/
InfluencerSeeder.php
routes/
web.php
api.php
# Not necessary for most applications. In case becomes too large, can consider splitting it.
application/
website/
web-routes.php
api/
api-routes.php
tests/
Domain/
Advertiser/
Actions/
ReviewInfluencerTest.php
Application/
Api/
Controllers/
GetInfluencersEndpointTest.php
Admin/