MarcinOrlowski / laravel-api-response-builder

Builds nice, normalized and easy to consume REST JSON responses for Laravel powered APIs.
MIT License
720 stars 80 forks source link

Class 'MarcinOrlowski\ResponseBuilder\RB' not found #162

Closed efriandika closed 4 years ago

efriandika commented 4 years ago

What's wrong?

In ResponseBuilderServiceProvider.php line 40:

  Class 'MarcinOrlowski\ResponseBuilder\RB' not found  

Steps to reproduce the behavior:

  1. Install it with latest laravel version and Laravel IDE Helper
MarcinOrlowski commented 4 years ago

RB is not a real class. It does not exist. It's an alias so you need to have it created with use as documented:

use MarcinOrlowski\ResponseBuilder\ResponseBuilder as RB;

or use ResponseBuilder instead of RB.

I'll improve docs to make it more clear.

efriandika commented 4 years ago

Thanks for the explanation, The solution you gave is possible if I move ResponseBuilderServiceProvider to my Providers directory, But if I only use autodiscover (ResponseBuilderServiceProvider from the package) it still produce the errors. Since I cannot see RB alias definition in laravel-api-response-builder/src/ResponseBuilderServiceProvider.php

PS: I am sorry if my english is bad.. I am beginner in english :D

MarcinOrlowski commented 4 years ago

Can you test this and tell if that solves the problem -> in your project's vendor/MarcinOrlowski/laravel-api-response-builder folder create RB.php file with the following content:

<?php
namespace MarcinOrlowski\ResponseBuilder;

class RB extends ResponseBuilder
{
}

then do composer dumpautoload and check if references to RB:: work without aliases. Let me know

efriandika commented 4 years ago

Hi I have made a pull request to solve this issue

MarcinOrlowski commented 4 years ago

I corrected Provider to not use RB alias. Adding use defates the purpose of using RB as it was mainly to short the files and provider refers ResponseBuilder only once. Thanks for the report. v9.0.1 is out now.