简体   繁体   English

在Laravel问题中定义自定义帮助程序类

[英]Defining custom helper class in laravel issue

I have created a folder called 'library' in Laravel app directory. 我在Laravel app目录中创建了一个名为“ library”的文件夹。 Then added a line to the following class in global.php . 然后在global.php的以下类中添加一行。

ClassLoader::addDirectories(array(

    app_path().'/commands',
    app_path().'/controllers',
    app_path().'/models',
    app_path().'/database/seeds',
    app_path() . '/library',

));

Then I did php artisan dump-autoload 然后我做了php artisan dump-autoload

But when I do this, it throws an error that the class is not defined: 但是,当我这样做时,会引发一个错误,即该类未定义:

$SMS = new sendSMS();

Have a look in your composer.json file, there is an autoload section in there. 看看您的composer.json文件,那里有一个自动加载部分。 Add the path in question to that section, run php artisan dump-autoload and you should be good to go. 将相关路径添加到该部分,运行php artisan dump-autoload ,您应该会很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM