简体   繁体   中英

3rd Party class in laravel

Here is what I've done so far.. based on this link Laravel cannot load 3rd party library

I followed all of it but still Im having this error

{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Class 'FileProcess' not found","file":"C:\\xampp\\htdocs\\fileshare\\trunk\\app\\controllers\\UserFilesController.php","line":437}}

my composer.json

"autoload": {
    "classmap": [
        "app/commands",
        "app/controllers",
        "app/library",
        "app/models",
        "app/database/migrations",
        "app/database/seeds",
        "app/tests/TestCase.php"
    ]
},

then my controller

<?php
 use \FileProcess;
 class UserFilesController extends \BaseController {


public function someMethod(){

$fp = new FileProcess;
}
}

then my 3rd party class which is located in app/library/FileProcess.php folder

<?php namespace FileProcess;

class FileProcess
{
   // some methods
}

i do not know what is wrong or if there is lacking

The reason Laravel can't find the class is because you have namespaced it and when you call it using use you are calling it from the Global namespace. Either of the following will fix it for you.

1) Remove namespace FileProcess; from the class file

2) In your controller call it using it's namespace use FileProcess\\FileProcess;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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