Skip to content

Instantly share code, notes, and snippets.

@pr1001
Created February 22, 2012 00:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pr1001/1880041 to your computer and use it in GitHub Desktop.
Save pr1001/1880041 to your computer and use it in GitHub Desktop.
Composer autoloading issue
{
"name": "bubblefoundry/Request",
"type": "library",
"description": "Request is a simple webapp framework that focusing on routing HTTP requests and returing responses.",
"keywords": ["http", "request", "response", "route"],
"authors": [{
"name": "Peter Robinett",
"email": "peter@bubblefoundry.com",
"homepage": "http://www.bubblefoundry.com"
}],
"version": "0.1.0",
"repositories": [{
"type": "vcs",
"url": "git://github.com/bubblefoundry/BFCollections.git"
}],
"require": {
"php": ">= 5.3.0",
"bubblefoundry/BFCollections": ">=0.1.0"
},
"autoload": {
"psr-0": {
"bubblefoundry/Request": "src/"
}
}
}
<?php
namespace bubblefoundry\Request;
// use composer for autoloading all dependencies
require 'vendor/.composer/autoload.php';
// from http://www.php.net/manual/en/class.errorexception.php
function exception_error_handler($errno, $errstr, $errfile, $errline ) {
throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
}
set_error_handler(__NAMESPACE__ .'\exception_error_handler');
$url = $_SERVER['REQUEST_URI'];
try {
// $response = Config::routes($url);
throw new \Exception("Not implemented yet");
}
catch (\Exception $e) {
// if match error, convert to 404
$response = new Response(404, "text/html", "Not found: $url");
}
header($response->status(), true, $response->code);
print $response->body;
?>

When I visit index.php I get:

Fatal error: Class 'bubblefoundry\Request\Response' not found in /home/beachhea/public_html/labs/request/index.php on line 23

The Response class is in /home/beachhea/public_html/labs/request/src/Response.php and is in the same namespace, bubblefoundry\Request\. I'm stumped about why it is not getting loaded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment