phpsharma
Members-
Posts
11 -
Joined
-
Last visited
-
Days Won
1
Everything posted by phpsharma
-
Hi , I made Tonic Rest application working using RedBean ORM wrapper without class dependency "Pimple". The real credit goes to "Slim" Rest Framework. Now I am able to work with both REST API's. Mean time I encountered with the concept/hands on CURL, JSON to really work with Total REST Cycle. I am happy to help anyone on this. REST Cycle. Its all started with this article.. http://www.huntlycameron.co.uk/2012/05/project-creating-a-restful-php-web-service-with-tonic/ Next to Slim.. http://www.sitepoint.com/writing-a-restful-web-service-with-slim/ http://www.slimframework.com Next to .. http://www.ibm.com/developerworks/opensource/library/x-slim-rest/index.html in the middle I got to know about..Pimple.. http://www.sitepoint.com/dependency-injection-with-pimple/ http://net.tutsplus.com/tutorials/php/dependency-injection-huh/ Finally End up Redbean ORM, CURL, http://www.lornajane.net/posts/2011/posting-json-data-with-php-curl The Book for PHP REST.. PHP Web Services on OReilly.com(Just 124 pages..) Thanks for your support.. sharma chelluri
-
Thanks for your prompt response. I am not getting errors. I am suspicious about there is no db connections from API? https://github.com/peej/tonic I checked the issues and the author is saying we need to write our own db wrapper. How do I do that? https://github.com/peej/tonic/issues/1#issuecomment-457804 it seems I need to have more oop. Please show me some light. Bit scared of namespaces, adapters etc ..nail biting Thanks, sharma
-
Hi Antonio, I am working on REst API called tonic using mongoDB.. I am able to connect to db outside the class.. $con = new MongoClient(); $db = $con->codesnippets; $collection = $db->snippets; //fetch a record $snippet = $collection->findOne(array("id" => 1)); print_r($snippet); When I put this in Rest API method its not working..and error is ....nothing <?php namespace Tyrell; use Tonic\Resource, Tonic\Response, Tonic\ConditionException; /** * This is a * * The @uri annotation routes requests that match that URL to this resource. Multiple * annotations allow this resource to match multiple URLs. * * @uri /snippets/:idhash */ class Snippet extends Resource { /** * @method GET * @provides application/json */ function display() { // Connect to mongodb $con = new \MongoClient(); $db = $con->codesnippets; $collection = $db->snippets; //print $this->idhash; //fetch record based on id $snippet = $collection->findOne(array("id" => $this->idhash)); print_r($snippet); exit; /*if(!is_null($snippet)){ $snippetArray = array('id' => $snippet["id"], 'title' => $snippet["title"], 'description' => $snippet["description"], 'links' => $snippet['links'], 'files' => $snippet['files'], 'dateCreated' => $snippet["date_created"], 'lastModified' => $snippet["last_modified"], 'views' => $snippet["views"]); } */ return json_encode($snippetArray); //$ds = $this->container['dataStore']; //return json_encode($ds->fetch($this->id)); } } Is it conflicting with name space ? can you please help me?.. I don't have much namespace knowledge. Thanks in advance, sharma
-
public function __construct() { $this->verb = $_SERVER['REQUEST_METHOD']; $this->url_elements = explode('/', $_SERVER['PATH_INFO']); $this->parseIncomingParams(); // initialise json as default format $this->format = 'json'; if(isset($this->parameters['format'])) { $this->format = $this->parameters['format']; } return true; } Hi , I remember that ___construct() didn't return any values.. On one of the tutorials on REst I have seen the code for creating a REst Server.. Can anyone please explain this?. How can they used it and any side effects? Source of the code: http://www.lornajane.net/posts/2012/building-a-restful-php-server-understanding-the-request Thanks in advance. sharma
-
Finally I catch the error with ifmodule.. http://www.askapache.com/htaccess/htaccess-for-webmasters.html <IfModule> should be<ifModule> if should be in small letters #<IfModule mod_rewrite.so> <ifModule mod_rewrite.c> # Turn on the engine: RewriteEngine on # Set the base to this directory: RewriteBase /php-oops/chp02/ # Redirect certain paths to index.php: RewriteRule ^(about|contact|this|that|search)/?$ index.php?p=$1 </ifModule> #</IfModule> Thanks Larry.. I love all your great work and way of writing/teaching. Your books made me proud after 10years of software developement. Now I am enjoying Programming more than before.. sharma
-
Hi, I added the below code in httpd.conf ++++++++++++++++++++++++++++++++++++++++++++ <Directory "C:/xampp/htdocs/php-oops/chp02"> AllowOverride All Require all granted </Directory> my htaccess file is like this ++++++++++++++++++++++++++++++++++++++++++++ # Script 2.7 - .htaccess <IfModule mod_rewrite.so> # Turn on the engine: RewriteEngine on # Set the base to this directory: RewriteBase /php-oops/chp02/ # Redirect certain paths to index.php: RewriteRule ^(about|contact|this|that|search)/?$ index.php?p=$1 </IfModule> Still not able to get the url rewrite working? xampp-httpd.conf? Thanks in advance sharma
-
Hi Great day, can anyone explain me this line of code ... "INDEX login(username, pass)" in the below query ************************************************************************* CREATE TABLE users ( user_id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT, lang_id TINYINT UNSIGNED NOT NULL, time_zone VARCHAR(30) NOT NULL, username VARCHAR(30) NOT NULL, pass CHAR(40) NOT NULL, email VARCHAR(60) NOT NULL, PRIMARY KEY(user_id), UNIQUE (username), UNIQUE (email), INDEX login(username, pass) ); ********************************************************** Thanks in advance, sharma