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
Loader::library('lobbyreeldashboard');
Inside of the library there is only one function right now called sayHello()
function sayHello() {
    return 'hello';
}


In my controller I make a call to the function using:
sayHello();
However, I receive the following error
Call to undefined function sayHello()


What am I missing to make this work in 5.7?

 
hutman replied on at Permalink Reply
hutman
In your library file you need to have

class lobbyreeldashboard {   
    function sayHello() {
        return 'hello';
    }
}


Then in your controller you call the function like this

lobbyreeldashboard::sayHello();
Jeremy1026 replied on at Permalink Reply
This doesn't work, now it can't find that class.

Class 'lobbyreeldashboard' not found
hutman replied on at Permalink Reply
hutman
Try saving it in a helpers folder instead of the libraries folder and then call it this way
<?php echo Loader::helper('lobbyrealdashboard')->sayHello(); ?>


https://www.concrete5.org/community/forums/5-7-discussion/helpers/...
Jeremy1026 replied on at Permalink Reply
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?
hutman replied on at Permalink Reply
hutman
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.
Jeremy1026 replied on at Permalink Reply
With that, where would I put my .php file?