Adding my custom libraries
Permalink
Hello guys ..
How can I add my custom php5 classes to my package and then be able to use them within the template view?
I mean .. certainly not within the controller right?
So where and how?
Thank you
How can I add my custom php5 classes to my package and then be able to use them within the template view?
I mean .. certainly not within the controller right?
So where and how?
Thank you
I don't understand .. is there an example ready somewhere?
I mean .. that's soo bloody confusing
I mean .. that's soo bloody confusing
Honestly .. for god sake .. It's not understandable ...
Is there any example .. bloody f**ing hell
Is there any example .. bloody f**ing hell
How the f**k this code can work .. for bloody god sake:
First, you can easily register custom autoloaders to points within the src/ directory. Let's say instead of Concrete\Package\Statistics\Src\Page\PageChecker we wanted to map this to MyVendor\ConcreteStatistics\Page\PageChecker. We'd just add this to our controller.php
protected $pkgAutoloaderRegistries = array(
'src/MyVendor/Statistics' => '\MyVendor\ConcreteStatistics'
);
Now, anything found inside src/MyVendor/Statistics/ will begin its namespace with MyVendor\ConcreteStatistics. So our page checker's class would be
namespace MyVendor\ConcreteStatistics\Page;
class PageChecker
{
}
And the file system would look like:
packages/statistics/src/MyVendor/Statistics/Page/PageChecker.php
and out on_start() method would look like this:
public function on_start()
{
$listener = \MyVendor\Statistics\Page\PageListener();
$listener->addListeners();
}
First, you can easily register custom autoloaders to points within the src/ directory. Let's say instead of Concrete\Package\Statistics\Src\Page\PageChecker we wanted to map this to MyVendor\ConcreteStatistics\Page\PageChecker. We'd just add this to our controller.php
protected $pkgAutoloaderRegistries = array(
'src/MyVendor/Statistics' => '\MyVendor\ConcreteStatistics'
);
Now, anything found inside src/MyVendor/Statistics/ will begin its namespace with MyVendor\ConcreteStatistics. So our page checker's class would be
namespace MyVendor\ConcreteStatistics\Page;
class PageChecker
{
}
And the file system would look like:
packages/statistics/src/MyVendor/Statistics/Page/PageChecker.php
and out on_start() method would look like this:
public function on_start()
{
$listener = \MyVendor\Statistics\Page\PageListener();
$listener->addListeners();
}
I am just the messenger.
I agree its confusing and dives into a lot of un-needed complexity before adequately explaining the basics. Just look back through the number of experienced developers posting here and suffering the same confusion you are. On the positive site, at least there is now something and up until a few months ago we had nothing.....
You only need to get into the complexities of registering autoloaders if you pull in a composer package that has its own autoloader. For your own classes, you can just stick to the naming conventions and the core autoloader should take care of it for you..
I agree its confusing and dives into a lot of un-needed complexity before adequately explaining the basics. Just look back through the number of experienced developers posting here and suffering the same confusion you are. On the positive site, at least there is now something and up until a few months ago we had nothing.....
You only need to get into the complexities of registering autoloaders if you pull in a composer package that has its own autoloader. For your own classes, you can just stick to the naming conventions and the core autoloader should take care of it for you..
For any 3rd party dependencies, you'll probably want to use composer. Here's an example how:
https://github.com/Buttress/addon_composer_sample/...
For any package specific classes, just give them the proper namespace (Concrete\Package\YourPackage\Src\...) and they are loaded automatically.
https://github.com/Buttress/addon_composer_sample/...
For any package specific classes, just give them the proper namespace (Concrete\Package\YourPackage\Src\...) and they are loaded automatically.
http://www.concrete5.org/documentation/developers/5.7/packages/addi...