Skip to content

Commit

Permalink
Merge pull request #2976 from Leantime/laravel11Update
Browse files Browse the repository at this point in the history
task: Update Laravel to 11
  • Loading branch information
marcelfolaron authored Mar 7, 2025
2 parents e78c6f0 + 029315d commit f2832c3
Show file tree
Hide file tree
Showing 17 changed files with 982 additions and 930 deletions.
3 changes: 0 additions & 3 deletions .idea/leantime-oss.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 8 additions & 6 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 11 additions & 69 deletions app/Core/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

namespace Leantime\Core;

use Illuminate\Log\Context\ContextServiceProvider;
use Illuminate\Log\LogServiceProvider;
use Illuminate\Routing\RoutingServiceProvider;
use Leantime\Core\Configuration\Environment;
use Leantime\Core\Console\ConsoleKernel;
use Leantime\Core\Events\DispatchesEvents;
use Leantime\Core\Http\ApiRequest;
use Leantime\Core\Http\HttpKernel;
use Leantime\Core\Http\IncomingRequest;
use Leantime\Core\Providers\Events;

Expand All @@ -33,27 +36,14 @@ class Application extends \Illuminate\Foundation\Application
public function __construct($basePath = null)
{

$this->publicPath = 'public/';
$this->namespace = 'Leantime\\';

if ($basePath) {
$this->setBasePath($basePath);
}

$this->appPath = $basePath.'/app/Core';

// Larevel stores cache in bootstrap folder
// Cache files are in root in Leantime not in bootstrap
// Env vars are not available in config

// putenv('APP_EVENTS_CACHE=cache/events.php');
// putenv('APP_CONFIG_CACHE=cache/config.php');
// putenv('APP_ROUTES_CACHE=cache/routes.php');
// putenv('APP_SERVICES_CACHE=cache/services.php');
// putenv('APP_PACKAGES_CACHE=cache/packages.php');

// Our folder structure is different and we shall not bow to the bourgeoisie
$this->useAppPath($this->basePath.'/app');
$this->useAppPath($this->basePath.'/app/Core');
$this->useConfigPath($this->basePath.'/config');
$this->useEnvironmentPath($this->basePath.'/config');
$this->useBootstrapPath($this->basePath.'/bootstrap');
Expand All @@ -63,16 +53,14 @@ public function __construct($basePath = null)
$this->useDatabasePath($this->basePath.'/database');

$this->registerBaseBindings();

// Loading some config vars so we can run events
// $this->register(new \Leantime\Core\Providers\Environment($this));

$this->registerBaseServiceProviders();
// $this->registerCoreContainerAliases();

$this->registerCoreContainerAliases();
// Overriding some of the aliases
$this->registerLeantimeAliases();

$this->registerLaravelCloudServices();

}

/**
Expand All @@ -89,6 +77,7 @@ protected function registerBaseServiceProviders()

$this->register(new \Leantime\Core\Providers\Events($this));
$this->register(new LogServiceProvider($this));
$this->register(new ContextServiceProvider($this));
$this->register(new RoutingServiceProvider($this));

// Todo: Add event and see if that works here.
Expand All @@ -98,55 +87,18 @@ protected function registerBaseServiceProviders()
public function registerLeantimeAliases()
{
foreach ([
'app' => [self::class, \Illuminate\Foundation\Application::class, \Illuminate\Contracts\Container\Container::class, \Illuminate\Contracts\Foundation\Application::class, \Psr\Container\ContainerInterface::class],
'auth' => [\Illuminate\Auth\AuthManager::class, \Illuminate\Contracts\Auth\Factory::class],
'auth.driver' => [\Illuminate\Contracts\Auth\Guard::class],
'blade.compiler' => [\Illuminate\View\Compilers\BladeCompiler::class],
'cache' => [\Illuminate\Cache\CacheManager::class, \Illuminate\Contracts\Cache\Factory::class],
'cache.store' => [\Illuminate\Cache\Repository::class, \Illuminate\Contracts\Cache\Repository::class, \Psr\SimpleCache\CacheInterface::class],
'cache.psr6' => [\Symfony\Component\Cache\Adapter\Psr16Adapter::class, \Symfony\Component\Cache\Adapter\AdapterInterface::class, \Psr\Cache\CacheItemPoolInterface::class],
'app' => [self::class, \Illuminate\Contracts\Container\Container::class, \Leantime\Core\Application::class, \Illuminate\Contracts\Foundation\Application::class, \Psr\Container\ContainerInterface::class],
'config' => [Environment::class, \Illuminate\Config\Repository::class, \Illuminate\Contracts\Config\Repository::class],
'cookie' => [\Illuminate\Cookie\CookieJar::class, \Illuminate\Contracts\Cookie\Factory::class, \Illuminate\Contracts\Cookie\QueueingFactory::class],
'db' => [\Illuminate\Database\DatabaseManager::class, \Illuminate\Database\ConnectionResolverInterface::class],
'db.connection' => [\Illuminate\Database\Connection::class, \Illuminate\Database\ConnectionInterface::class],
'db.schema' => [\Illuminate\Database\Schema\Builder::class],
'encrypter' => [\Illuminate\Encryption\Encrypter::class, \Illuminate\Contracts\Encryption\Encrypter::class, \Illuminate\Contracts\Encryption\StringEncrypter::class],
'events' => [\Leantime\Core\Events\EventDispatcher::class, \Illuminate\Events\Dispatcher::class, \Illuminate\Contracts\Events\Dispatcher::class],
'files' => [\Illuminate\Filesystem\Filesystem::class],
'filesystem' => [\Illuminate\Filesystem\FilesystemManager::class, \Illuminate\Contracts\Filesystem\Factory::class],
'filesystem.disk' => [\Illuminate\Contracts\Filesystem\Filesystem::class],
'filesystem.cloud' => [\Illuminate\Contracts\Filesystem\Cloud::class],
'hash' => [\Illuminate\Hashing\HashManager::class],
'hash.driver' => [\Illuminate\Contracts\Hashing\Hasher::class],
// 'translator' => [\Illuminate\Translation\Translator::class, \Illuminate\Contracts\Translation\Translator::class],
'log' => [\Illuminate\Log\LogManager::class, \Psr\Log\LoggerInterface::class],
// 'mail.manager' => [\Illuminate\Mail\MailManager::class, \Illuminate\Contracts\Mail\Factory::class],
// 'mailer' => [\Illuminate\Mail\Mailer::class, \Illuminate\Contracts\Mail\Mailer::class, \Illuminate\Contracts\Mail\MailQueue::class],
// 'auth.password' => [\Illuminate\Auth\Passwords\PasswordBrokerManager::class, \Illuminate\Contracts\Auth\PasswordBrokerFactory::class],
// 'auth.password.broker' => [\Illuminate\Auth\Passwords\PasswordBroker::class, \Illuminate\Contracts\Auth\PasswordBroker::class],
// 'queue' => [\Illuminate\Queue\QueueManager::class, \Illuminate\Contracts\Queue\Factory::class, \Illuminate\Contracts\Queue\Monitor::class],
// 'queue.connection' => [\Illuminate\Contracts\Queue\Queue::class],
// 'queue.failer' => [\Illuminate\Queue\Failed\FailedJobProviderInterface::class],
'redirect' => [\Illuminate\Routing\Redirector::class],
'redis' => [\Illuminate\Redis\RedisManager::class, \Illuminate\Contracts\Redis\Factory::class],
'redis.connection' => [\Illuminate\Redis\Connections\Connection::class, \Illuminate\Contracts\Redis\Connection::class],
'request' => [IncomingRequest::class, ApiRequest::class, Console\CliRequest::class, \Illuminate\Http\Request::class, \Symfony\Component\HttpFoundation\Request::class],
'router' => [\Illuminate\Routing\Router::class, \Illuminate\Contracts\Routing\Registrar::class, \Illuminate\Contracts\Routing\BindingRegistrar::class],
'session' => [\Illuminate\Session\SessionManager::class],
'session.store' => [\Illuminate\Session\Store::class, \Illuminate\Contracts\Session\Session::class],
'url' => [\Illuminate\Routing\UrlGenerator::class, \Illuminate\Contracts\Routing\UrlGenerator::class],
'validator' => [\Illuminate\Validation\Factory::class, \Illuminate\Contracts\Validation\Factory::class],
'view' => [\Illuminate\View\Factory::class, \Illuminate\Contracts\View\Factory::class],
] as $key => $aliases) {
foreach ($aliases as $alias) {
$this->alias($key, $alias);
}
}

$this->alias(Application::class, \Illuminate\Contracts\Foundation\Application::class);
$this->alias(HttpKernel::class, \Illuminate\Foundation\Http\Kernel::class);
$this->alias(ConsoleKernel::class, \Illuminate\Foundation\Console\Kernel::class);

// $this->alias(DispatchesEvents::class, 'events');
// $this->alias(Environment::class, 'config');
}

// Boot with Leantime event dispatcher
Expand All @@ -171,14 +123,4 @@ public function boot()
self::dispatchEvent('afterBootingServiceProviders');

}

/**
* Set the application as having been bootstrapped
*/
public static function setHasBeenBootstrapped(): self
{
self::$bootstrapped = true;

return self::getInstance();
}
}
4 changes: 0 additions & 4 deletions app/Core/Bootloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ private function __construct() {}
*/
public function boot(Application $app)
{
if (! defined('LEANTIME_START')) {
define('LEANTIME_START', microtime(true));
}

// Start Application
// Load the bindings and service providers
$this->app = $app;
Expand Down
3 changes: 3 additions & 0 deletions app/Core/Configuration/laravelConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -848,4 +848,7 @@
],

],
'hashing' => [
'rehash_on_login' => false,
],
];
2 changes: 1 addition & 1 deletion app/Core/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct(Container $laravel, Dispatcher $events, $version)
*
* @return int 0 if everything went fine, or an error code
*/
public function doRun(InputInterface $input, OutputInterface $output)
public function doRun(InputInterface $input, OutputInterface $output): int
{
// $this->setDomain($input);

Expand Down
2 changes: 1 addition & 1 deletion app/Core/Events/EventDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ public static function getFilterRegistry(): array
*/
public function hasListeners($eventName)
{
return array_key_exists($eventName, $this->eventRegistry);
return array_key_exists($eventName, self::$eventRegistry);

}

Expand Down
38 changes: 19 additions & 19 deletions app/Core/Http/HttpKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,25 @@ class HttpKernel extends Kernel
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
];

public function handle($request)
{
$this->requestStartedAt = Carbon::now();

try {
$response = $this->sendRequestThroughRouter($request);
} catch (\Throwable $e) {
$this->reportException($e);

$response = $this->renderException($request, $e);
}

$this->app['events']->dispatch(new RequestHandled($request, $response));

$response = self::dispatch_filter('beforeSendResponse', $response);

return $response;
}

protected function sendRequestThroughRouter($request)
{
$this->app->instance('request', $request);
Expand Down Expand Up @@ -146,25 +165,6 @@ function: 'handle',
return $response;
}

public function handle($request)
{
$this->requestStartedAt = Carbon::now();

try {
$response = $this->sendRequestThroughRouter($request);
} catch (\Throwable $e) {
$this->reportException($e);

$response = $this->renderException($request, $e);
}

$this->app['events']->dispatch(new RequestHandled($request, $response));

$response = self::dispatch_filter('beforeSendResponse', $response);

return $response;
}

public function terminate($request, $response)
{

Expand Down
10 changes: 0 additions & 10 deletions app/Core/Http/IncomingRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,10 @@ class IncomingRequest extends \Illuminate\Http\Request

protected $currentRoute;

protected $basePath;

private $basePathCalculated = false;

private $pathInfoCalculated = false;

public $headers = [];

protected $requestUri;

public $query;

public $request;

public const HEADER_FORWARDED = parent::HEADER_FORWARDED; // When using RFC 7239

public const HEADER_X_FORWARDED_FOR = parent::HEADER_X_FORWARDED_FOR;
Expand Down
2 changes: 1 addition & 1 deletion app/Core/Providers/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function register()

$app['config']->set('cache.stores.'.$domainCacheName.'.driver', 'redis');
$app['config']->set('cache.stores.'.$domainCacheName.'.connection', 'cache');
$app['config']->set('cache.stores.'.$domainCacheName.'.prefix', ''.$domainCacheName.'');
$app['config']->set('cache.stores.'.$domainCacheName.'.prefix', ''.$domainCacheName.':');

}

Expand Down
1 change: 0 additions & 1 deletion app/Core/Providers/Sanctum.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public function register(): void

public function boot(): void
{
SanctumBase::ignoreMigrations();

// Use our custom token model
SanctumBase::usePersonalAccessTokenModel(AccessToken::class);
Expand Down
2 changes: 1 addition & 1 deletion app/Domain/Auth/Services/AuthUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function validateCredentials(Authenticatable $user, array $credentials)
);
}

public function rehashPasswordIfRequired() {}
public function rehashPasswordIfRequired(Authenticatable $user, array $credentials, bool $force = false) {}

public function getOrCreateUser($user, $source)
{
Expand Down
2 changes: 1 addition & 1 deletion app/Domain/Timesheets/Services/Timesheets.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public function getWeeklyTimesheets(int $projectId, CarbonInterface $fromDate, i
}
// Detect timezone offset

$workdateOffsetStart = ($currentWorkDate->setToUserTimezone()->secondsSinceMidnight() / 60 / 60);
$workdateOffsetStart = (int) ($currentWorkDate->setToUserTimezone()->secondsSinceMidnight() / 60 / 60);

// Various Entries can be in different timezones and thus would not be caught by upsert or grouping by
// default Creating new rows for each timezone adjustment
Expand Down
27 changes: 13 additions & 14 deletions bootstrap/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,6 @@
! defined('ROOT') ? define('ROOT', __DIR__.'/../public') : '';
! defined('APP_ROOT') ? define('APP_ROOT', dirname(__DIR__, 1)) : '';

/*
|--------------------------------------------------------------------------
| Check If The Application Is Under Maintenance
|--------------------------------------------------------------------------
|
| If the application is in maintenance / demo mode via the "down" command
| we will load this file so that any pre-rendered content can be shown
| instead of starting the framework, which could cause an exception.
|
*/
if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) {
require $maintenance;
}

/*
|--------------------------------------------------------------------------
| Create The Application
Expand Down Expand Up @@ -73,3 +59,16 @@
*/

return $app;

// return Application::configure(basePath: dirname(__DIR__))
// ->withRouting(
// web: __DIR__.'/../routes/web.php',
// commands: __DIR__.'/../routes/console.php',
// health: '/up',
// )
// ->withMiddleware(function (Middleware $middleware) {
// //
// })
// ->withExceptions(function (Exceptions $exceptions) {
// //
// })->create();;
Loading

0 comments on commit f2832c3

Please sign in to comment.