Libraries in 5.7
Permalink
How do libraries work in 5.7? I am trying to utilize a custom library for use on a single page.
I have created the single page view and controller. I am able to access the controller from the view.
I also created a library in application/libraries/ called lobbreeldashboard.php.
In my controller I have Inside of the library there is only one function right now called sayHello()
In my controller I make a call to the function using: However, I receive the following error
What am I missing to make this work in 5.7?
I have created the single page view and controller. I am able to access the controller from the view.
I also created a library in application/libraries/ called lobbreeldashboard.php.
In my controller I have
Loader::library('lobbyreeldashboard');
function sayHello() { return 'hello'; }
In my controller I make a call to the function using:
sayHello();
Call to undefined function sayHello()
What am I missing to make this work in 5.7?
This doesn't work, now it can't find that class.
Class 'lobbyreeldashboard' not found
Try saving it in a helpers folder instead of the libraries folder and then call it this way
https://www.concrete5.org/community/forums/5-7-discussion/helpers/...
<?php echo Loader::helper('lobbyrealdashboard')->sayHello(); ?>
https://www.concrete5.org/community/forums/5-7-discussion/helpers/...
Reading the link, it seems like I may have come into my problem. I'm not writing a package. Can I only use a library in a package now?
From what I can see there is no such thing as a Library in 5.7, but you can use helpers, if you look at the line of code in my last post that is how you would get a helper that is not in a package.
With that, where would I put my .php file?
Then in your controller you call the function like this