The group you are posting to is a
Usenet group . Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
From:
"Mariano C." <mariano.calan... @gmail.com>
Date: Sun, 29 Jul 2012 07:49:36 -0700 (PDT)
Local: Sun, Jul 29 2012 10:49 am
Subject: [2.1] Problem with webservices
I'm try to develop a simple webservices in CakePHP 2.1. So, i first created a DB table:
CREATE TABLE IF NOT EXISTS `people` (
> `id` char(36) COLLATE utf8_bin NOT NULL, > `first_name` varchar(100) COLLATE utf8_bin DEFAULT NULL, > `last_name` varchar(100) COLLATE utf8_bin NOT NULL, > `home_address` varchar(100) COLLATE utf8_bin DEFAULT NULL, > `job_address` varchar(100) COLLATE utf8_bin DEFAULT NULL, > `phone` varchar(20) COLLATE utf8_bin DEFAULT NULL, > `fax` varchar(20) COLLATE utf8_bin DEFAULT NULL, > `mail` varchar(100) COLLATE utf8_bin DEFAULT NULL, > `birth_date` int(11) DEFAULT NULL > ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin
Than I've created a simple Person model:
<?php
> class Person extends AppModel { > public $name = 'Person'; > }
And respective controller:
<?php
> class PeopleController extends AppController {
> public $components = array('RequestHandler');
> public function index() { > $people = $this->Person->find('all'); > $this->set(array( > 'people' => $people, > '_serialize' => array('person') > )); > } > }
and finally, in routes.php, I've mapped the proper roote:
<?php
> Router::mapResources('people'); > Router::parseExtensions('json'); > Router::connect('/', array('controller' => 'pages', 'action' => > 'display', 'home')); > Router::connect('/pages/*', array('controller' => 'pages', 'action' => > 'display')); > CakePlugin::routes(); > require CAKE . 'Config' . DS . 'routes.php';
but when I try to reach ht_tp://localhost/cakephp/people.json I get:
<pre class="cake-error"><a href="javascript:void(0);"
> onclick="document.getElementById('cakeErr501541d86308c-trace').style.displa y > = (document.getElementById('cakeErr501541d86308c-trace').style.display == > 'none' ? '' : 'none');"><b>Notice</b> (8)</a>: Undefined index: person > [<b>CORE\Cake\View\JsonView.php</b>, line <b>89</b>]<div > id="cakeErr501541d86308c-trace" class="cake-stack-trace" style="display: > none;"><a href="javascript:void(0);" > onclick="document.getElementById('cakeErr501541d86308c-code').style.display > = (document.getElementById('cakeErr501541d86308c-code').style.display == > 'none' ? '' : 'none')">Code</a> <a href="javascript:void(0);" > onclick="document.getElementById('cakeErr501541d86308c-context').style.disp lay > = (document.getElementById('cakeErr501541d86308c-context').style.display == > 'none' ? '' : 'none')">Context</a><pre id="cakeErr501541d86308c-code" > class="cake-code-dump" style="display: none;"><code><span style="color: > #000000"> $this->autoRend er = false;</span></code> > <code><span style="color: > #000000"> $this->View&nbs p;= $View;</span></code> > <span class="code-highlight"><code><span style="color: > #000000"> $this->response ->body($View->render($view, $layout));</span></code></span></pre ><pre > id="cakeErr501541d86308c-context" class="cake-context" style="display: > none;">$view = null > $layout = null > $serialize = array( > (int) 0 => 'person' > ) > $data = array() > $key = 'person'</pre><pre > class="stack-trace">JsonView::render() - CORE\Cake\View\JsonView.php, line > 89 > Controller::render() - CORE\Cake\Controller\Controller.php, line 957 > Dispatcher::_invoke() - CORE\Cake\Routing\Dispatcher.php, line 193 > Dispatcher::dispatch() - CORE\Cake\Routing\Dispatcher.php, line 161 > [main] - APP\webroot\index.php, line > 92</pre></div></pre>{"person":null}
Where is the error?
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Walter Raponi <walter.rap... @gmail.com>
Date: Sun, 29 Jul 2012 17:15:55 +0200
Local: Sun, Jul 29 2012 11:15 am
Subject: Re: [2.1] Problem with webservices
Missing view under View/People/json/index.ctp
Just echo json_encode($people); there and you should get yout json data
=============================
Walter Raponi
Din S.r.l.
Via Donato Menichella 304
00156 Roma - Italy
Tel 0641227662
Fax 0641227664
w.rap... @ritoll.it
Il giorno 29/lug/2012, alle ore 16:49, "Mariano C." <mariano.calan... @gmail.com> ha scritto:
> I'm try to develop a simple webservices in CakePHP 2.1. So, i first created a DB table:
> CREATE TABLE IF NOT EXISTS `people` (
> `id` char(36) COLLATE utf8_bin NOT NULL,
> `first_name` varchar(100) COLLATE utf8_bin DEFAULT NULL,
> `last_name` varchar(100) COLLATE utf8_bin NOT NULL,
> `home_address` varchar(100) COLLATE utf8_bin DEFAULT NULL,
> `job_address` varchar(100) COLLATE utf8_bin DEFAULT NULL,
> `phone` varchar(20) COLLATE utf8_bin DEFAULT NULL,
> `fax` varchar(20) COLLATE utf8_bin DEFAULT NULL,
> `mail` varchar(100) COLLATE utf8_bin DEFAULT NULL,
> `birth_date` int(11) DEFAULT NULL
> ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin
> Than I've created a simple Person model:
> <?php
> class Person extends AppModel {
> public $name = 'Person';
> }
> And respective controller:
> <?php
> class PeopleController extends AppController {
> public $components = array('RequestHandler');
> public function index() {
> $people = $this->Person->find('all');
> $this->set(array(
> 'people' => $people,
> '_serialize' => array('person')
> ));
> }
> }
> and finally, in routes.php, I've mapped the proper roote:
> <?php
> Router::mapResources('people');
> Router::parseExtensions('json');
> Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
> Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
> CakePlugin::routes();
> require CAKE . 'Config' . DS . 'routes.php';
> but when I try to reach ht_tp://localhost/cakephp/people.json I get:
> <pre class="cake-error"><a href="javascript:void(0);" onclick="document.getElementById('cakeErr501541d86308c-trace').style.displa y = (document.getElementById('cakeErr501541d86308c-trace').style.display == 'none' ? '' : 'none');"><b>Notice</b> (8)</a>: Undefined index: person [<b>CORE\Cake\View\JsonView.php</b>, line <b>89</b>]<div id="cakeErr501541d86308c-trace" class="cake-stack-trace" style="display: none;"><a href="javascript:void(0);" onclick="document.getElementById('cakeErr501541d86308c-code').style.display = (document.getElementById('cakeErr501541d86308c-code').style.display == 'none' ? '' : 'none')">Code</a> <a href="javascript:void(0);" onclick="document.getElementById('cakeErr501541d86308c-context').style.disp lay = (document.getElementById('cakeErr501541d86308c-context').style.display == 'none' ? '' : 'none')">Context</a><pre id="cakeErr501541d86308c-code" class="cake-code-dump" style="display: none;"><code><span style="color: #000000"> $this->autoRend er = false;</span></code>
> <code><span style="color: #000000"> $this->View&nbs p;= $View;</span></code>
> <span class="code-highlight"><code><span style="color: #000000"> $this->response ->body($View->render($view, $layout));</span></code></span></pre ><pre id="cakeErr501541d86308c-context" class="cake-context" style="display: none;">$view = null
> $layout = null
> $serialize = array(
> (int) 0 => 'person'
> )
> $data = array()
> $key = 'person'</pre><pre class="stack-trace">JsonView::render() - CORE\Cake\View\JsonView.php, line 89
> Controller::render() - CORE\Cake\Controller\Controller.php, line 957
> Dispatcher::_invoke() - CORE\Cake\Routing\Dispatcher.php, line 193
> Dispatcher::dispatch() - CORE\Cake\Routing\Dispatcher.php, line 161
> [main] - APP\webroot\index.php, line 92</pre></div></pre>{"person":null}
> Where is the error?
> -- > Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
"Mariano C." <mariano.calan... @gmail.com>
Date: Sun, 29 Jul 2012 08:35:23 -0700 (PDT)
Local: Sun, Jul 29 2012 11:35 am
Subject: Re: [2.1] Problem with webservices
Nothing change, I got the same error. :(
Il giorno domenica 29 luglio 2012 16:49:36 UTC+2, Mariano C. ha scritto:
> I'm try to develop a simple webservices in CakePHP 2.1. So, i first > created a DB table:
> CREATE TABLE IF NOT EXISTS `people` ( >> `id` char(36) COLLATE utf8_bin NOT NULL, >> `first_name` varchar(100) COLLATE utf8_bin DEFAULT NULL, >> `last_name` varchar(100) COLLATE utf8_bin NOT NULL, >> `home_address` varchar(100) COLLATE utf8_bin DEFAULT NULL, >> `job_address` varchar(100) COLLATE utf8_bin DEFAULT NULL, >> `phone` varchar(20) COLLATE utf8_bin DEFAULT NULL, >> `fax` varchar(20) COLLATE utf8_bin DEFAULT NULL, >> `mail` varchar(100) COLLATE utf8_bin DEFAULT NULL, >> `birth_date` int(11) DEFAULT NULL >> ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin
> Than I've created a simple Person model:
> <?php >> class Person extends AppModel { >> public $name = 'Person'; >> }
> And respective controller:
> <?php >> class PeopleController extends AppController { >> public $components = array('RequestHandler');
>> public function index() { >> $people = $this->Person->find('all'); >> $this->set(array( >> 'people' => $people, >> '_serialize' => array('person') >> )); >> } >> }
> and finally, in routes.php, I've mapped the proper roote:
> <?php >> Router::mapResources('people'); >> Router::parseExtensions('json'); >> Router::connect('/', array('controller' => 'pages', 'action' => >> 'display', 'home')); >> Router::connect('/pages/*', array('controller' => 'pages', 'action' >> => 'display')); >> CakePlugin::routes(); >> require CAKE . 'Config' . DS . 'routes.php';
> but when I try to reach ht_tp://localhost/cakephp/people.json I get:
> <pre class="cake-error"><a href="javascript:void(0);" >> onclick="document.getElementById('cakeErr501541d86308c-trace').style.displa y >> = (document.getElementById('cakeErr501541d86308c-trace').style.display == >> 'none' ? '' : 'none');"><b>Notice</b> (8)</a>: Undefined index: person >> [<b>CORE\Cake\View\JsonView.php</b>, line <b>89</b>]<div >> id="cakeErr501541d86308c-trace" class="cake-stack-trace" style="display: >> none;"><a href="javascript:void(0);" >> onclick="document.getElementById('cakeErr501541d86308c-code').style.display >> = (document.getElementById('cakeErr501541d86308c-code').style.display == >> 'none' ? '' : 'none')">Code</a> <a href="javascript:void(0);" >> onclick="document.getElementById('cakeErr501541d86308c-context').style.disp lay >> = (document.getElementById('cakeErr501541d86308c-context').style.display == >> 'none' ? '' : 'none')">Context</a><pre id="cakeErr501541d86308c-code" >> class="cake-code-dump" style="display: none;"><code><span style="color: >> #000000"> $this->autoRend er = false;</span></code> >> <code><span style="color: >> #000000"> $this->View&nbs p;= $View;</span></code> >> <span class="code-highlight"><code><span style="color: >> #000000"> $this->response ->body($View->render($view, $layout));</span></code></span></pre ><pre >> id="cakeErr501541d86308c-context" class="cake-context" style="display: >> none;">$view = null >> $layout = null >> $serialize = array( >> (int) 0 => 'person' >> ) >> $data = array() >> $key = 'person'</pre><pre >> class="stack-trace">JsonView::render() - CORE\Cake\View\JsonView.php, line >> 89 >> Controller::render() - CORE\Cake\Controller\Controller.php, line 957 >> Dispatcher::_invoke() - CORE\Cake\Routing\Dispatcher.php, line 193 >> Dispatcher::dispatch() - CORE\Cake\Routing\Dispatcher.php, line 161 >> [main] - APP\webroot\index.php, line >> 92</pre></div></pre>{"person":null}
> Where is the error?
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
rchavik <rcha... @gmail.com>
Date: Sun, 29 Jul 2012 09:35:37 -0700 (PDT)
Local: Sun, Jul 29 2012 12:35 pm
Subject: Re: [2.1] Problem with webservices
On Sunday, July 29, 2012 10:35:23 PM UTC+7, Mariano C. wrote:
> Nothing change, I got the same error. :(
Read the error message:
<b>Notice</b> (8)</a>: Undefined index: person [<b>CORE\Cake\View\JsonView.php</b>, line <b>89</b>
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
"Mariano C." <mariano.calan... @gmail.com>
Date: Sun, 29 Jul 2012 10:01:12 -0700 (PDT)
Local: Sun, Jul 29 2012 1:01 pm
Subject: Re: [2.1] Problem with webservices
Yes I've read that message, but I don't understand what it means. Why I get that error only in json and xml output and not in a normal view?
Il giorno domenica 29 luglio 2012 18:35:37 UTC+2, rchavik ha scritto:
> On Sunday, July 29, 2012 10:35:23 PM UTC+7, Mariano C. wrote:
>> Nothing change, I got the same error. :(
> Read the error message:
> <b>Notice</b> (8)</a>: Undefined index: person > [<b>CORE\Cake\View\JsonView.php</b>, line <b>89</b>
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Walter Raponi <walter.rap... @gmail.com>
Date: Sun, 29 Jul 2012 21:41:24 +0200
Local: Sun, Jul 29 2012 3:41 pm
Subject: Re: [2.1] Problem with webservices
$this->set(array(
'people' => $people,
'_serialize' => array('person')
));
Do we need serialize??
Just try $this->set('person', $people);
And in view Echo json_encode($person);
=============================
Walter Raponi
Din S.r.l.
Via Donato Menichella 304
00156 Roma - Italy
Tel 0641227662
Fax 0641227664
w.rap... @ritoll.it
Il giorno 29/lug/2012, alle ore 19:01, "Mariano C." <mariano.calan... @gmail.com> ha scritto:
> Yes I've read that message, but I don't understand what it means. Why I get that error only in json and xml output and not in a normal view?
> Il giorno domenica 29 luglio 2012 18:35:37 UTC+2, rchavik ha scritto:
> On Sunday, July 29, 2012 10:35:23 PM UTC+7, Mariano C. wrote:
> Nothing change, I got the same error. :(
> Read the error message:
> <b>Notice</b> (8)</a>: Undefined index: person [<b>CORE\Cake\View\JsonView.php</b>, line <b>89</b> > -- > Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
WyriHaximus <webmas... @wyrihaximus.net>
Date: Sun, 29 Jul 2012 13:48:52 -0700 (PDT)
Local: Sun, Jul 29 2012 4:48 pm
Subject: Re: [2.1] Problem with webservices
Why would do you that when you can make the JsonView take care of that:
$this->set(array( 'people' => $people, '_serialize' => array('people') ));
On Sunday, July 29, 2012 9:41:24 PM UTC+2, Walter Raponi wrote:
> $this->set(array( > 'people' => $people, > '_serialize' => array('person') > ));
> Do we need serialize??
> Just try $this->set('person', $people);
> And in view > Echo json_encode($person);
> ============================= > *Walter Raponi* > Din S.r.l. > Via Donato Menichella 304 > 00156 Roma - Italy
> Tel 0641227662 > Fax 0641227664 > w.rap... @ritoll.it
> Il giorno 29/lug/2012, alle ore 19:01, "Mariano C." < > mariano.calan... @gmail.com> ha scritto:
> Yes I've read that message, but I don't understand what it means. Why I > get that error only in json and xml output and not in a normal view?
> Il giorno domenica 29 luglio 2012 18:35:37 UTC+2, rchavik ha scritto:
>> On Sunday, July 29, 2012 10:35:23 PM UTC+7, Mariano C. wrote:
>>> Nothing change, I got the same error. :(
>> Read the error message:
>> <b>Notice</b> (8)</a>: Undefined index: person >> [<b>CORE\Cake\View\JsonView.php</b>, line <b>89</b>
> -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions.
> To unsubscribe from this group, send email to > cake-php+unsubscribe@googlegroups.com For more options, visit this group > at http://groups.google.com/group/cake-php
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
"Mariano C." <mariano.calan... @gmail.com>
Date: Sun, 29 Jul 2012 14:25:48 -0700 (PDT)
Local: Sun, Jul 29 2012 5:25 pm
Subject: Re: [2.1] Problem with webservices
It's working now, but I followed the name convention as written on cake site.
Il giorno domenica 29 luglio 2012 22:48:52 UTC+2, WyriHaximus ha scritto:
> Why would do you that when you can make the JsonView take care of that:
> $this->set(array( > 'people' => $people, > '_serialize' => array('people') > ));
> On Sunday, July 29, 2012 9:41:24 PM UTC+2, Walter Raponi wrote:
>> $this->set(array( >> 'people' => $people, >> '_serialize' => array('person') >> ));
>> Do we need serialize??
>> Just try $this->set('person', $people);
>> And in view >> Echo json_encode($person);
>> ============================= >> *Walter Raponi* >> Din S.r.l. >> Via Donato Menichella 304 >> 00156 Roma - Italy
>> Tel 0641227662 >> Fax 0641227664 >> w.rap... @ritoll.it
>> Il giorno 29/lug/2012, alle ore 19:01, "Mariano C." < >> mariano.calan... @gmail.com> ha scritto:
>> Yes I've read that message, but I don't understand what it means. Why I >> get that error only in json and xml output and not in a normal view?
>> Il giorno domenica 29 luglio 2012 18:35:37 UTC+2, rchavik ha scritto:
>>> On Sunday, July 29, 2012 10:35:23 PM UTC+7, Mariano C. wrote:
>>>> Nothing change, I got the same error. :(
>>> Read the error message:
>>> <b>Notice</b> (8)</a>: Undefined index: person >>> [<b>CORE\Cake\View\JsonView.php</b>, line <b>89</b>
>> -- >> Our newest site for the community: CakePHP Video Tutorials >> http://tv.cakephp.org >> Check out the new CakePHP Questions site http://ask.cakephp.org and help >> others with their CakePHP related questions.
>> To unsubscribe from this group, send email to >> cake-php+unsubscribe@googlegroups.com For more options, visit this group >> at http://groups.google.com/group/cake-php
You must
Sign in before you can post messages.
You do not have the permission required to post.