Composer class not found error on class alias in Laravel

Problem intro:


I’m implementing a custom caching solution that utilizes a file store but still allows tagging.

For this, I’ve installed some packages which are irrelevant to the question. The problem occurs with my facade implementation.

I’ve created a ServiceProvider (which is registered in Laravel 11’s providers.php) for this implementation, where I bind a class from the composer package to taggable-cache. Here, I’ve also used the AliasLoaded to register the TCache alias for my Facade class.

namespace AppProviders;

use AlternativeLaravelCacheStoreAlternativeFileCacheStoreWithLocks;
use IlluminateFoundationAliasLoader;
use IlluminateSupportServiceProvider;

class TaggableCacheServiceProvider extends ServiceProvider
{
    /**
     * Register services.
     */
    public function register(): void
    {
        //
        $this->app->bind('taggable-cache', function() {
            /** @var AlternativeFileCacheStoreWithLocks $store */
            $store = app('cache')->store('file');

            return $store;
        });
    }

    /**
     * Bootstrap services.
     */
    public function boot(): void
    {
        $aliasLoader = AliasLoader::getInstance();

        $aliasLoader->alias('TCache', AppFacadesTaggableCacheFacade::class);
    }
}

Of course, this comes with the aforementioned Facade, which is quite simple

namespace AppFacades;

use IlluminateSupportFacadesFacade;

class TaggableCacheFacade extends Facade
{
    protected static function getFacadeAccessor(): string
    {
        return 'taggable-cache';
    }
}

Unsure if related to the issue


I ran into an issue where PhpStorm was unable to ‘recognize’ the TCache class. To fix this I installed the package barryvdh/laravel-ide-helper. This allowed me to generate an _ide_helper.php file and fixes the issue of PhpStorm not recognizing the class.

Actual errors


After setting this up and confirming it works as intended I tried running composer install to test if the commands I added in the "post-update-cmd" hook worked, except I now keep running into the following error:

// The command:

composer i

// Output:

Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Nothing to install, update or remove
Package sinergi/browser-detector is abandoned, you should avoid using it. No replacement was suggested.
Generating optimized autoload files
> IlluminateFoundationComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

   Error 

  Class "TCache" not found

  at app/Services/RouteService.php:446
    442▕      * @return array
    443▕      */
    444▕     private function getAcceptedRouteParameters(): array
    445▕     {
  ➜ 446▕         return TCache::tags(CacheTag::ROUTES->value)->rememberForever(
    447▕             "accepted_route_parameters",
    448▕             function () {
    449▕                 return [
    450▕                     'locale' => ['locale'],

  1   app/Services/RouteService.php:39
      AppServicesRouteService::getAcceptedRouteParameters()

  2   [internal]:0
      AppServicesRouteService::__construct()

Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

Before I ran composer install everything was working as expected, but now I keep getting the Class not found errors, both in the console and the front end of my website, keep in mind that this was working fine before I ran composer install.

I tried running other commands, like composer dump-autoload to see if that would help. I also removed the scripts from "post-update-cmd" and ran composer install again to no avail. So I am now unable to run any commands, also php artisan commands.

Does anyone have an idea on how to fix this issue?

Project details:

Package Version
PHP 8.3.8
laravel/framework 11.15.0
statamic/cms 5.13.0
barryvdh/laravel-ide-helper 3.0.0
swayok/alternative-laravel-cache 6.1.16
swayok/cache-filesystem-adapter 1.3.2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật