2

I started a laravel project in version 5.5, I have been working with version 5.1.

In this version I use the folder 'nob' and I use it to develop some classes to turn them into components.

I used the following composer.json in the version 5.1:

"autoload": {
    "classmap": [
        "database"
    ],
    "psr-4": {
        "App\\": "app/",
        "Nob\\": "nob/"
    }
},

And this is the version 5.5:

"autoload": {
    "classmap": [
        "database/seeds",
        "database/factories"
    ],
    "psr-4": {
        "App\\": "app/",
        "Nob\\": "nob/"
    }
},

I get this error: enter image description here

This is the class, her namespace is correct

<?php namespace Nob\Payeezy\Types;

use Nob\Payeezy\Payeezy;

class Authorization extends Payeezy
{

And this is the tree:

enter image description here

I use PhpStorm and he recognizes the namespace enter image description here

I do not know what may be happening, I used composer dump-autoload and nothing.

Derek Pollard
  • 6,953
  • 6
  • 39
  • 59
Elias Tutungi
  • 330
  • 1
  • 3
  • 6
  • Is ``config.optimize-autoloader`` in composer.json set to true? If so, take a look at this: https://stackoverflow.com/questions/25619063/composer-classmap-autoload-does-not-load-new-files-in-folder – SameOldNick Jan 06 '18 at 01:27
  • Yes, its is set to true, i removed composer.lock file and used composer update. I'm waiting for it to end :/ – Elias Tutungi Jan 06 '18 at 16:14
  • Nothing, its not work :/ – Elias Tutungi Jan 06 '18 at 16:45
  • 1
    If nothing is working, I'd suggest evaluating why you need your core application code outside of the ``App`` namespace and not in a namespace like ``App\Classes\Nob``. Maybe it should be it's own package? If so, you can have [Composer load private packages](https://getcomposer.org/doc/05-repositories.md#vcs) and [see Laravel's documentation on developing packages](https://laravel.com/docs/5.5/packages). – SameOldNick Jan 06 '18 at 17:54
  • The reason is that I worked so well in 5.1 and it worked perfectly, everything of nob does not belong exclusively to that application because I will use it in other projects that I do in parallel, so I do not consider it to be part of the app, but if in 5.5 is the only way that will work, so I'll have to do it like that. – Elias Tutungi Jan 07 '18 at 14:28

2 Answers2

6

Your code is correct when I tried on my PhpStorm. But you can run the following three commands:

$ php artisan clear-compiled 
$ composer dump-autoload
$ php artisan optimize

And this will clear the current compiled files, update the classes it needs and then write them back out so you don't have to do it again.

common sense
  • 3,775
  • 6
  • 22
  • 31
Joan Nguyen
  • 372
  • 1
  • 5
  • `$ php artisan optimize` is deprecated in Laravel 5.5 (and does nothing) and will be removed in 5.6. https://laravel-news.com/laravel-5-6-removes-artisan-optimize – common sense Jan 06 '18 at 14:24
  • Y use php artisan clear-compiled and composer dump-autoload and nothing.. :/ – Elias Tutungi Jan 06 '18 at 16:08
0

You can use this commands may can help you:

composer dump-autoload -o

Good Luck

Gautam Patadiya
  • 1,401
  • 14
  • 19