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?
@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.
@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');
@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
@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.
@martinbean I found the problem. Problem coming use onurozdogan\CloudflareImageApi\Facades\CloudflareImageApi from CloudflareImageApiServiceProvider When I delete use problem fixed