0

I have a problem with autoloading Restler. I wanted to use a bootstrap/autoloader in my application and looked at this tutorial, which was good for me as a PHP beginner. But it doesn't work with Restler. Why?

Composer created/downloaded all files without any problem.

This is my code for the bootstrap.php:

 <?php
 require_once dirname(__FILE__) . '/../vendor/autoload.php';

And this is my index.php (Restler) file:

 <?php
 #require_once '/../../vendor/luracast/restler/vendor/restler.php';
 require_once dirname(__FILE__) . '/../bootstrap.php';
 use Luracast\Restler\Restler;
 use Luracast\Restler\Defaults;

 Defaults::$throttle = 20;

 $r = new Restler();
 $r -> addAPIClass('defaultCall', '');
 $r -> addAPIClass('API');
 $r -> handle();

But it doesn't work. If I change the '#' and load the restler.php file as usual, everything works.

Any suggestions?

Siguza
  • 21,155
  • 6
  • 52
  • 89
LuMa
  • 1,673
  • 3
  • 19
  • 41
  • FYI: You can stop using `dirname(__FILE__)` because PHP 5.3 and up supports `__DIR__` directly, which is the same. And please add more details, because "doesn't work" does not describe what you did (which URL did you call? How?) and what you got back (error messages in the browser or in any log file?) Did you increase the error reporting? Did you turn on `display_errors`? – Sven Nov 23 '14 at 17:54
  • @Sven Thanks for your reply. Take a look at my code [here](http://pastebin.com/NU9fWfqr). Using 'require_once `/../../vendor/luracast/restler/vendor/restler.php';` to load restler works. But if I use the composer autoloader with `'require_once __DIR__ . '/../vendor/autoload.php';'` in my bootstrap.php I get the following (error)response when calling `localhost`: `{ "error": { "code": 404, "message": "Not Found" }, "debug": { "source": "Routes.php:359 at route stage", "stages": }, }` I cut the debug part of the message due to char lim in comments – LuMa Nov 23 '14 at 18:52
  • `localhost` is opening index.php in the browser which should show me a short message on screen (defaultCall), if everything works. However, I don't get an error in the php log. – LuMa Nov 23 '14 at 19:01
  • It seems like you have installed it wrong. Show the `composer.json` file you are using. And – Sven Nov 27 '14 at 21:41

0 Answers0