Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

onurzdgn's avatar

Create Personal Package

Hello everyone. I am using Laravel 11 and I will learn how to create my own package. This is my https://packagist.org/packages/onurozdogan/cloudflare-image-api package link. I add my laravel 11 project this package, when I want to use it give me error. The error: Class "onurozdogan\CloudflareImageApi\Facades\CloudflareImageApi" not found. I am stuck here. How can I fix this problem?

0 likes
8 replies
martinbean's avatar
Level 80

@onurzdgn The error is telling you what’s wrong: the class you are requesting was not found. That then means you’ve got something about the namespace wrong; either when importing or in the file itself.

Looking at the GitHub repository for the project, you’ve declared in your composer.json is Onurozdogan\\CloudflareImageApi\\ but then in your façade class you’re using onurozdogan\CloudflareImageApi\Facades (lowercase “o” at the start).

Namespaces are case-sensitive. So the autoloader can’t find the file because you’ve told it that your namespace starts with Onurozdogan (uppercase “O”) but then used onurozdogan (lowercase “o”) in your actual files.

1 like
onurzdgn's avatar

@martinbean Yes I miss it. Now I fix but this time it gives me Target class [cloudflare_image_api] does not exist. error from my facades. Also this is my facades:

 protected static function getFacadeAccessor(): string
    {
        return 'cloudflare_image_api';
    }

Register function:

 $this->app->singleton('cloudflare_image_api', function ($app) {
            return new CloudflareImageApi();
        });
        $this->mergeConfigFrom(__DIR__ . '/../config/cloudflareimageapi.php', 'cloudflareimageapi');
onurzdgn's avatar

@martinbean Thank you again I fixed to. I know it is to much but I have one more problem. Call to undefined method onurozdogan\CloudflareImageApi\Facades\CloudflareImageApi::upload() it can't see my function

martinbean's avatar

@onurzdgn Well I don’t think you’ve fixed the original issue since the error message still has onurozdogan (all-lowercase).

onurzdgn's avatar

@martinbean I control all files multiple time however I can't see something other than onurozdogan

martinbean's avatar

@onurzdgn You should not have any class names or namespaces with all-lowercase names. They should be named using StudlyCase (i.e. Onurozdogan ) as per one of my previous comments. So please go and fix that.

onurzdgn's avatar

@martinbean I found the problem. Problem coming use onurozdogan\CloudflareImageApi\Facades\CloudflareImageApi from CloudflareImageApiServiceProvider When I delete use problem fixed

Please or to participate in this conversation.