How to add custom php classes in Laravel 5.5?

When I started my first laravel project, I had requirement for uploading big images. So I decided to use a well image library jQuery-File-Upload from Blue Imp. But one problem I do not know how to inlcude the thirdparty library in the Laravel. After researching a lot in forums and other sites, I got the below.

Everything in Laravel 5 is autoloaded using PSR-4, within the app directory. It is mentioned very clearly in the composer.json file.

Basically, you can create another directory within app folder, and then namespace your files. So I have created a two folders in my app folder ThirdParty,FileUpload respectively.

Suppose your file is app\ThirdParty\FileUpload\UploadHandler.php, the namespace would be:

namespace App\ThirdParty\FileUpload;

Then, within your controller class make sure you namespace it:




Editorial Staff

Editorial Staff at tutsplanet is a dedicated team to write various tutorial articles.