Migrating from 5.7 to 5.8

Permalink 1 user found helpful
Hi,
I'm testing concrete5 8.0.5 on a virtual machine. After installing it, it appears that something has changed in the way namespaces are managed. In concrete 5.7.5.13, I was doing :
use \Application\Src\Calis2\UserManagement;

to use the class UserManagement in
application/src/Calis2

but in 8.0.4 this is no more valid.

Do you know why?

And can you point me to a list of what to check in source code for migrating from 7 to 8?

Thank you!

 
Gondwana replied on at Permalink Reply
Gondwana
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi VonUniGE,

To expand on Gondwana's reply, there is documentation covering the changes to autoloading in v8:

Creating Custom Code in the Application Directory
http://documentation.concrete5.org/developers/extending-concrete5-w...

Adding Custom Code to Packages
http://documentation.concrete5.org/developers/packages/adding-custo...
VonUniGE replied on at Permalink Best Answer Reply
As explained, in the documentation, I've added in application/bootstrap/app.php:
$classLoader = new \Symfony\Component\ClassLoader\Psr4ClassLoader();
$classLoader->addPrefix('Application\\Calis2', DIR_APPLICATION . '/' . DIRNAME_CLASSES . '/Calis2');
$classLoader->register();

And remove Src in every occurence of
namespace Application\Src\Calis2;

and in every occurence of
use Application\Src\Calis2\MyClass;

and this issue is solved.

I could also simply add :
'enable_legacy_src_namespace' => true

in application/config/app.php but I prefer not to rely on legacy support. And I also think that it's much cleaner to not have this not significant Src in paths.

Thank you for your help.