Skip to main content

Global Configuration

Global configuration belongs in AppServiceProvider::register().

Use this file for framework-wide behaviour that every request needs: resources, auth handlers, feature flags and frontend URL settings. Keep feature-specific setup close to the feature when it does not affect the whole application.

use function Qore\Next\System\Helpers\qore;

qore()
->registerResource(new UserResource)
->setAuthMiddleware(['api', 'auth:sanctum'])
->setLoginHandler(fn (User $user) => Auth::guard('web')->login($user))
->setLogoutHandler(fn (?Model $model = null) => Auth::guard('web')->logout())
->setIsBroadcastingEnabled(config('broadcasting.default') === 'reverb');

Common options

  • registerResource() makes a resource available to routes, globals, menus and relation fields.
  • setAuthMiddleware() defines the middleware used by Qore API routes. ApplyPreferences is always appended.
  • setLoginHandler() and setLogoutHandler() let the application decide how sessions are created and destroyed.
  • setUserDisplay() customizes how users are shown by user relation fields.
  • setIsBroadcastingEnabled(), setIsGlobalSearchEnabled() and setIsNotificationsEnabled() toggle global features.
  • setIsExportingEnabledByDefault() changes the default export behaviour for resources.
  • setFrontendUrlPrefix() is used by frontend_url() and resource URL helpers.

Globals

Globals are app-wide values returned to the frontend: resources, modules, preferences, broadcasting status, global search status, notification status and unread notification count.

They exist so layout-level UI can render without every page repeating the same requests.

Frontend app config

Frontend configuration is passed to QoreAppProvider in resources/js/app.tsx.

Use it for SPA concerns: API client, router, layouts, i18n, default language, theme tokens and global API error handlers.

<QoreAppProvider
app={{
apiEndpoint: import.meta.env.VITE_API_URL,
appTitle: import.meta.env.VITE_APP_NAME,
router,
api,
appLayout: QoreAppLayout,
guestLayout: GuestLayout,
authMiddleware,
i18n,
defaultLanguage: 'nl',
theme: ({ darkMode }) => ({
layout: { colorPrimary: darkMode ? '#60a5fa' : '#2563eb' }
})
}}
/>