Support the ongoing development of Laravel.io →
Security Architecture Testing

Hello,

I have an API called restclient.php. What basically happens is that I'll include the restclient.php in any page I want to use it and then I can access a class say $testApi = new apiTest ();

what I did with laravel is to include restclient.php in global and try to use $testApi = new apiTest (); but I keep getting class not found error.

I will appreciate it if anyone can direct me.

Thanks

Last updated 3 years ago.
0

You have to autoload from your composer.json


{
    "autoload": {
        "files": ["restclient.php"]
    }
}

0

Thanks RemiCollin but it didn't work. I have some error

[Seld\JsonLint\ParsingException]
"./composer.json" does not contain valid JSON
Parse error on line 10:
... "classmap": [ //"files": ["restcli
--------------------^
Expected one of: 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', ']'

0

You must have a missing comma somewhere. Paste your composer.json.

0

{ "name": "laravel/laravel", "description": "The Laravel Framework.", "keywords": ["framework", "laravel"], "license": "MIT", "require": { "laravel/framework": "4.2.*" }, "autoload": { "classmap": [ "files": ["restclient.php"], "app/commands", "app/controllers", "app/models", "app/database/migrations", "app/database/seeds", "app/tests/TestCase.php"

	]
},
"scripts": {
	"post-install-cmd": [
		"php artisan clear-compiled",
		"php artisan optimize"
	],
	"post-update-cmd": [
		"php artisan clear-compiled",
		"php artisan optimize"
	],
	"post-create-project-cmd": [
		"php artisan key:generate"
	]
},
"config": {
	"preferred-install": "dist"
},
"minimum-stability": "stable"

}

Last updated 10 years ago.
0

"files" should be outside of "classmap"

0

Sign in to participate in this thread!

PHPverse

Your banner here too?

sparkandy sparkandy Joined 28 Sep 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.