Concrete 8.0 Binds

Permalink
Im getting this error and im not sure why. Im testing out the new Concrete5 version, 8.0.

http://clients.designedbygerry.com/concrete8/index.php?cID=1at... the following url you can see the error.

I created a test class located in Application/Src. Its called Testing.php
namespace Application\Src;
use Config;
class Testing{
    function testing(){
        return "test";
    }
}


In Application\Bootstrap\app.php :
Core::bind('testing', function() {
    return new Application\Src\Testing();
});




Can someone tell me why version 8.0 doesnt like this bind function?

 
Gondwana replied on at Permalink Reply
Gondwana
I've got around similar problems by having require Testing.php in in app.php. Inelegant, and probably not the c5 way of doing things, but...
glin425 replied on at Permalink Reply
might be a temp solution, just so I can keep developing. Thank you for this =] But does anyone know if there is a new way to do binds or should I or has someone else reported this bug to core team?
Gondwana replied on at Permalink Reply
Gondwana
Just looking athttp://www.php-fig.org/psr/psr-4/...
I don't suppose it works if you put a \ before your class reference; eg, new \Application\Src\Testing()
glin425 replied on at Permalink Reply
Thanks for the continued support, truly appreciate the help. I have tried this as well to no avail.
Gondwana replied on at Permalink Reply
Gondwana
My next wild uninformed stab: capitalisation? Consider
http://documentation.concrete5.org/developers/background/coding-sty...
glin425 replied on at Permalink Reply
All my namespaces and file names and class names are capitalized. I tried capitalizing the name of my alias from testing to Testing. The error changed to "Could not find the class Testing"
glin425 replied on at Permalink Reply
Anyone else run into this issue that could help me out?
andrew replied on at Permalink Best Answer Reply
andrew
We have made some changes to the concrete5 class loader. I will post updates on those changes today; in a nutshell, we have turned off the Application\Src namespace by default, for a number of reasons.

You can roll your own autoloaders (which will be described in this documentation) but obviously that's pretty inconvenient. If you want to get things working quickly again, you can re-enable this legacy support by adding this array to application/config/app.php:

'enable_legacy_src_namespace' => true

(make sure that file returns a valid array.)

Hope this helps.
glin425 replied on at Permalink Reply
Andrew, Ill look forward to learning about rolling my own autoloaders. Your config variable you supplied me with did work. Thank you very much! Very helpful.
andrew replied on at Permalink Reply
andrew
Glad to hear it. I have posted updated documentation which should hopefully answer any questions you may have, whether it's about your own autoloaders or about providing custom code in packages.

http://documentation.concrete5.org/developers/extending-concrete5-w...
webinstinct replied on at Permalink Reply
webinstinct
Andrew:

1. If Application/Src is now a legacy way to load in our own code, then how should it properly be done in 8.0?

2. How is this handled when upgrading a site from 5.7? Would our custom code (in Application/Src) be ignored after upgrade, until we added that line?
andrew replied on at Permalink Reply
andrew
Good questions. Currently, we aren't enabling the legacy src namespace on upgrade – but I could definitely see us enabling it for legacy sites.

I have posted the updated documentation on this topic; hopefully it clears up a lot of these questions:

http://documentation.concrete5.org/developers/extending-concrete5-w...