eaponz
eaponz

Reputation: 604

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

Upvotes: 0

Views: 1860

Answers (1)

RMcLeod
RMcLeod

Reputation: 2581

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;

Upvotes: 1

Related Questions