From e4972e1bf06d6527e4533fc843c12494be5a03cd Mon Sep 17 00:00:00 2001 From: PJ Dietz Date: Thu, 10 Jan 2013 20:09:07 -0500 Subject: [PATCH] Refactored namespace Added autoload to composer.json --- Handler.inc.php | 2 +- Message.inc.php | 2 +- Request.inc.php | 2 +- Response.inc.php | 2 +- Route.inc.php | 2 +- Router.inc.php | 2 +- composer.json | 3 +++ exceptions/CurlException.inc.php | 2 +- exceptions/WellrestedException.inc.php | 2 +- samples/apisample/ApiSampleRouter.inc.php | 12 ++++++++---- .../handlers/ArticleCollectionHandler.inc.php | 2 +- .../apisample/handlers/ArticleItemHandler.inc.php | 2 +- samples/client-side-request-and-response.php | 2 +- samples/client-side-request.php | 2 +- samples/server-side-request-and-response.php | 2 +- samples/server-side-response.php | 2 +- 16 files changed, 25 insertions(+), 18 deletions(-) diff --git a/Handler.inc.php b/Handler.inc.php index 0eaf01d..92830af 100644 --- a/Handler.inc.php +++ b/Handler.inc.php @@ -1,6 +1,6 @@ =5.3.0" + }, + "autoload": { + "psr-0": { "pjdietz/WellRESTed": "" } } } diff --git a/exceptions/CurlException.inc.php b/exceptions/CurlException.inc.php index cf49a28..7a06590 100644 --- a/exceptions/CurlException.inc.php +++ b/exceptions/CurlException.inc.php @@ -1,6 +1,6 @@ addTemplate('/articles/{id}', 'ArticleItemHandler', 'ArticleItemHandler.inc.php', - array('id' => \wellrested\Route::RE_NUM)); + array('id' => Route::RE_NUM)); $this->addTemplate('/articles/{slug}', 'ArticleItemHandler', 'ArticleItemHandler.inc.php', - array('slug' => \wellrested\Route::RE_SLUG)); + array('slug' => Route::RE_SLUG)); } @@ -36,7 +40,7 @@ class ApiSampleRouter extends \wellrested\Router { $handlerClassName = '\apisample\handlers\\' . $handlerClassName; $handlerFilePath = dirname(__FILE__) . '/handlers/' . $handlerFilePath; - $this->addRoute(\wellrested\Route::newFromUriTemplate( + $this->addRoute(Route::newFromUriTemplate( $template, $handlerClassName, $handlerFilePath, $variables)); } diff --git a/samples/apisample/handlers/ArticleCollectionHandler.inc.php b/samples/apisample/handlers/ArticleCollectionHandler.inc.php index f9e2262..f005545 100644 --- a/samples/apisample/handlers/ArticleCollectionHandler.inc.php +++ b/samples/apisample/handlers/ArticleCollectionHandler.inc.php @@ -8,7 +8,7 @@ require_once(dirname(__FILE__) . '/../ArticlesController.inc.php'); /** * Handler class for a list of articles. */ -class ArticleCollectionHandler extends \wellrested\Handler { +class ArticleCollectionHandler extends \pjdietz\WellRESTed\Handler { /** * Respond to a GET request. diff --git a/samples/apisample/handlers/ArticleItemHandler.inc.php b/samples/apisample/handlers/ArticleItemHandler.inc.php index 20be1f3..85bcce2 100644 --- a/samples/apisample/handlers/ArticleItemHandler.inc.php +++ b/samples/apisample/handlers/ArticleItemHandler.inc.php @@ -11,7 +11,7 @@ require_once(dirname(__FILE__) . '/../ArticlesController.inc.php'); * When instantiated by the Router, this class should receive an id or slug * argument to identify the article. */ -class ArticleItemHandler extends \wellrested\Handler { +class ArticleItemHandler extends \pjdietz\WellRESTed\Handler { /** * Respond to a GET request. diff --git a/samples/client-side-request-and-response.php b/samples/client-side-request-and-response.php index 1940753..294e203 100644 --- a/samples/client-side-request-and-response.php +++ b/samples/client-side-request-and-response.php @@ -14,7 +14,7 @@ require_once('../Request.inc.php'); require_once('../Response.inc.php'); // Make a custom request to talk to the server. -$rqst = new \wellrested\Request(); +$rqst = new \pjdietz\WellRESTed\Request(); // Use the client-site-endpoint.php script $rqst->hostname = $_SERVER['HTTP_HOST']; diff --git a/samples/client-side-request.php b/samples/client-side-request.php index e2970cd..822d15a 100644 --- a/samples/client-side-request.php +++ b/samples/client-side-request.php @@ -8,7 +8,7 @@ require_once('../Request.inc.php'); // Make a requst to Google in one line: -$rqst = new \wellrested\Request(); +$rqst = new \pjdietz\WellRESTed\Request(); $rqst->uri = 'https://www.google.com/search?q=my+search+terms'; // You could also set the members individually, like this: diff --git a/samples/server-side-request-and-response.php b/samples/server-side-request-and-response.php index f0c7e84..6c90013 100644 --- a/samples/server-side-request-and-response.php +++ b/samples/server-side-request-and-response.php @@ -12,7 +12,7 @@ require_once('../Request.inc.php'); require_once('../Response.inc.php'); // Read the request sent to the server as the singleton instance. -$rqst = \wellrested\Request::getRequest(); +$rqst = \pjdietz\WellRESTed\Request::getRequest(); // Alternatively, you can create a new Request and call readHttpRequest(). // $rqst = new \wellrested\Request(); diff --git a/samples/server-side-response.php b/samples/server-side-response.php index e4964a1..446bbd5 100644 --- a/samples/server-side-response.php +++ b/samples/server-side-response.php @@ -7,7 +7,7 @@ require_once('../Response.inc.php'); // Create a new Response instance. -$resp = new \wellrested\Response(); +$resp = new \pjdietz\WellRESTed\Response(); $resp->statusCode = 200; $resp->setHeader('Content-Type', 'text/plain'); $resp->body = 'This is a response.';