Re: CakePHP 2.0 authentication(login) without ctp files but other types

2015-01-13 Thread Joe T.
i'm not sure if/how you can disable Auth's automatic hashing of the 
password value to authenticate the login. In any case, i'd be very careful 
about doing so. i have a very basic understanding of that component. 

Someone else would have to speak to that, and any ideas for converting the 
existing user record's password without setting up a new account. i don't 
know if there are that many options. Security sacrifices a good amount of 
flexibility in cases like this.

-joe


On Sunday, 11 January 2015 06:52:07 UTC-5, tech_me wrote:

  If '123' is the actual data in your password field in the data record, 
 it's very likely this is the problem you're having with logging in.
 Maybe this is the problem;)

  That's why i recommended setting up the create-user form from the 
 tutorial. 
  It will set up the creation of the user record, which will encrypt the 
 password you supply and store *that* version in the table for comparison 
 during login.
 I will try the CTP style login soon.
 But, could I use existed (user) data if I just wanted to test my login 
 success or failure with session functionality?
 Not want to do the creating user process before other implementations.

 Thank you,
 tech_me


 On Tuesday, January 6, 2015 at 9:11:07 AM UTC+9, Joe T. wrote:

  Is that the actual data in `users`, or just simplified for example? 
 Just want to clarify. Manually adding records won't work in this case. 
 It is the actual data which is storing in my `users` table.

 If '123' is the actual data in your password field in the data record, 
 it's very likely this is the problem you're having with logging in.

 The line
   if ($this-Auth-login()) { ...
 fails because Auth-login() method encrypts the POST password, turning '
 *123*' into something like *$2y$10$VgMbmaJ5l96WJYJeU*... (in other 
 words, an encrypted version of '*123*'). The encrypted string is 
 compared to the database value more or less *as-is*. It expects the 
 database value to *already* be encrypted. If they match, login passes. 
 In your case:

 Encrypted POST password *$2y$10$VgMbmaJ5l96WJYJeU*... *!==* stored 
 password value *123*, so login fails.

 That's why i recommended setting up the create-user form from the 
 tutorial. It will set up the creation of the user record, which will 
 encrypt the password you supply and store *that* version in the table 
 for comparison during login.

 When i said you should adapt it to your needs, i meant the way the 
 tutorial demonstrates the Form builder for CTP may not match exactly what 
 you need for TAL. i'm unfamiliar with that, so if ignore that part if it 
 was more confusing. :)

 Hope that clears things up a *little*. :)
 -joe


 On Sunday, 4 January 2015 01:59:27 UTC-5, tech_me wrote:

 Hi Joe, 
 Happy New Year!

 I'm sorry for delaying reply you.
  Is that the actual data in `users`, or just simplified for example? 
 Just want to clarify. Manually adding records won't work in this case. 
 It is the actual data which is storing in my `users` table.

  Auth automatically encrypts the submitted password  compares it to 
 the database value. If you enter '123' as the password, it's not going to 
 match '123' in the database after Auth encrypts it.
 I don't know this issue, but entered the password `123` just as it have 
 been stored in my table.
 Maybe this is the problem...I'll check it.

  Obviously, adapt the CTP form to your TAL needs.
 What this means? Are you talking about the usage in my controller but 
 not html(TAL) files for login?

 Regards,
 tech_me


 On Tuesday, December 23, 2014 11:35:40 PM UTC+9, Joe T. wrote:

 Is that the actual data in `users`, or just simplified for example? 
 Just want to clarify. Manually adding records won't work in this case. 
 Auth 
 automatically encrypts the submitted password  compares it to the 
 database 
 value. If you enter '123' as the password, it's not going to match '123' 
 in 
 the database after Auth encrypts it.

 Look here for how to set up adding/editing users: 
 http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html
 Obviously, adapt the CTP form to your TAL needs.

 Hope that helps...
 -joe t.


 On Monday, 22 December 2014 20:42:33 UTC-5, tech_me wrote:

 By the way, I have a table `users` in my db, which have 2 records.
 id,   email,  password
 1001, abc@com, 123
 1002, abc@org, 456

 When I input email and password on the login form, it fails at `if 
 ($this-Auth-login())`


 On Tuesday, December 23, 2014 10:39:39 AM UTC+9, tech_me wrote:

 In my view file(html)
 form method=POST tal:attributes=action string:/users/login
 input type=text name=email size=15 maxlength=30 
 placeholder=your email /br /
 input type=password name=password size=15 maxlength=15 
 placeholder=password /br /
 input type=submit value=login /
 /form

 In my AppController.php
 public $components = array('RequestHandler',
 'Auth' = array(
 'authenticate' = array(
 

Re: 3.0: Saving new entity with belongsToMany data

2015-01-13 Thread José Lorenzo
I think you should put your code somewhere so we can take a look, otherwise 
trying to guess what the problem is will take a while.

On Tuesday, January 13, 2015 at 4:02:56 AM UTC+1, Joe T. wrote:

 Wondering if someone can help me take a closer look at this... i'm still 
 not having any luck  can't really get much forward progress until i 
 understand this.

 If you need more information to determine suggestions, let me know. Any 
 suggestions are appreciated.

 -joe


 On Tuesday, 30 December 2014 01:52:54 UTC-5, Joe T. wrote:

 i figured out part of my trouble, but the purpose of the original post 
 still remains.

 The parent record in Listings wasn't saving correctly because i didn't 
 have an `active` field in the form (*facepalm*). Corrected that. Still 
 having trouble with the date field, kinda frustrated there. But to the 
 point...

 When i save my data, i'm now getting a record in Listings. Yay! But the 
 associated data in ListingsAttrs is still not there. Boo!

 Current structure of ListingsAttrs POST data:
 [listings_attrs] = Array (
 [4] = Array (
 [attr_id] = 4
 )
 [1] = Array (
 [attr_id] = 1
 [value] = Off-street
 )
 )

 Which now gives me this in the *$listing* Entity:
 listings_attrs: {
 4: {
 attr_id: 4
 },
 1: {
 attr_id: 1,
 value: Off-street
 }
 }

 This is progress! The associated data wasn't in previous debug data.

 So what am i still missing that it won't save that data? Remember, 
 `value` is optional to the data record, it's controlled by the UI. So 
 both of those records *should be* valid. Why then is neither of them 
 being saved?

 Any additional help here is appreciated.
 -joe t.


 On Monday, 22 December 2014 22:54:12 UTC-5, Joe T. wrote:

 Sorry this took several days to respond, i was sick all weekend, didn't 
 get anywhere near my computer.

 i changed the names of the inputs from *listingsattrs*  
 *listings_attrs* as you recommended (no clue how i missed that to begin 
 with). My POST data now looks exactly as it did before, except for the name 
 of that particular item. However, the log output for the $listing 
 entity is still missing the associated ListingsAttrs data.

 The ListingsAttrs Entity didn't have a $_accessible array, so i added a 
 default:
 $_accessible = [
   '*' = true
 ];

 The controller code looks like:
 $listing = $this-Listings-newEntity($this-request-data);

 /* i've also tried:
 $listing = $this-Listings-newEntity($this-request-data, 
 ['associated' = ['ListingsAttrs']]);
 $listing = $this-Listings-newEntity($this-request-data, 
 ['associated' = ['ItemAttrs']]);
 $listing = $this-Listings-newEntity($this-request-data, 
 ['associated' = ['ListingsAttrs.ItemAttrs']]);
 $listing = $this-Listings-newEntity($this-request-data, 
 ['associated' = ['ItemAttrs.ListingsAttrs']]);
 */

 if ($this-Listings-save($listing)) {
   // etc.
 }
 else {
   throw new Exception...
 }

 What else can i try? i appreciate the help.
 -joe

 On Friday, 19 December 2014 11:29:12 UTC-5, José Lorenzo wrote:

 You should post a property called listings_attrs, check your entity 
 $_accessible array to make sure the property is also writable with request 
 data.

 On Friday, December 19, 2014 6:29:43 AM UTC+1, Joe T. wrote:

 i've seen a couple similar threads about this, but not my exact 
 problem.

 i'm trying to follow the guide here: 
 http://book.cakephp.org/3.0/en/orm/saving-data.html#converting-request-data-into-entities
  
 and coming up short. *i'm not getting any errors* (except a date 
 field that constantly fails if it has a value, separate issue)...so i 
 have 
 no idea what's happening to the data i submit, or why it isn't saved to 
 the 
 DB.

 My raw response data logged to Cake Debug is:

 Array (
   [title] = '123 Main St'
   [street] = '123 Main St'
   [lot_no] = 1
   [lat] =
   [lng] =
   [city] = 'Hometown'
   [county] = 
   [state] = 'MI'
   [zip] = '49000'
   [area] = 900 
   [bedrooms] = 2 
   [bathrooms] = 1 
   [price] = 525 
   [ready_date] =
   [listingsattrs] = Array (
 [4] = Array (
   [id] = 4
 )
 [1] = Array (
   [id] = 1
   [value] = 'Off-street'
 )
   )
   [park_id] = 1
   [house_condition_id] = 3
   [house_style_id] = 2 
   [term_id] = 2
   [info_body] = 'pLive here. It#39;s great!/p'
 ) 

 i have tables *Listings*, *ItemAttrs*, and *ListingsAttrs*. In 
 *ListingsTable*, the relationship is defined as:
 $this-addAssociations([
   'belongsToMany' = [
 'ItemAttrs' = [
   'targetForeignKey' = 'attr_id',
   'through'  = 'ListingsAttrs',
   'saveStrategy' = 'replace',
   ]
 ])'

 *Some* attributes are required to have a value when assigned to a 
 Listing (or other parent object they can be assigned to with a similar 
 relationship). When a requires-value attribute is selected for the (in 
 this 
 case) Listing, a text field is shown  marked as required. The value is 
 stored in the 

URL rewriting is not properly configured on your server

2015-01-13 Thread Anchit Jindal
While running CakePHP on my system, I am getting the following error:

URL rewriting is not properly configured on your server. 1) Help me 
configure it 2) I don't / can't use URL rewriting

mod_rewrite is enabled on server. 


The thing which look suspicious to me is that the following files in root 
folder are named incorrectly:

.htaccess is named as _htaccess
.editorconfig is named as _editorconfig
.gitignore is named as _editorconfig
.travis.yml is named as _travi.yml


When I tried to rename these files according to their correct name, it gave 
'Internal Server Error'. 

Please help me in resolving the error.



Thanks

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Cakephp rediffmail issues

2015-01-13 Thread Sudhir Pandey
resolved 

Remove the title form html layout

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: 3.0: Saving new entity with belongsToMany data

2015-01-13 Thread Joe T.
https://bitbucket.org/cautionbug/kodiak-investments

The stuff i'm having trouble with is behind an admin login. If you need 
access, i'd prefer to send that privately.

Thanks for responding  being willing to take a look.

-joe


On Tuesday, 13 January 2015 03:38:36 UTC-5, José Lorenzo wrote:

 I think you should put your code somewhere so we can take a look, 
 otherwise trying to guess what the problem is will take a while.

 On Tuesday, January 13, 2015 at 4:02:56 AM UTC+1, Joe T. wrote:

 Wondering if someone can help me take a closer look at this... i'm still 
 not having any luck  can't really get much forward progress until i 
 understand this.

 If you need more information to determine suggestions, let me know. Any 
 suggestions are appreciated.

 -joe


 On Tuesday, 30 December 2014 01:52:54 UTC-5, Joe T. wrote:

 i figured out part of my trouble, but the purpose of the original post 
 still remains.

 The parent record in Listings wasn't saving correctly because i didn't 
 have an `active` field in the form (*facepalm*). Corrected that. Still 
 having trouble with the date field, kinda frustrated there. But to the 
 point...

 When i save my data, i'm now getting a record in Listings. Yay! But the 
 associated data in ListingsAttrs is still not there. Boo!

 Current structure of ListingsAttrs POST data:
 [listings_attrs] = Array (
 [4] = Array (
 [attr_id] = 4
 )
 [1] = Array (
 [attr_id] = 1
 [value] = Off-street
 )
 )

 Which now gives me this in the *$listing* Entity:
 listings_attrs: {
 4: {
 attr_id: 4
 },
 1: {
 attr_id: 1,
 value: Off-street
 }
 }

 This is progress! The associated data wasn't in previous debug data.

 So what am i still missing that it won't save that data? Remember, 
 `value` is optional to the data record, it's controlled by the UI. So 
 both of those records *should be* valid. Why then is neither of them 
 being saved?

 Any additional help here is appreciated.
 -joe t.


 On Monday, 22 December 2014 22:54:12 UTC-5, Joe T. wrote:

 Sorry this took several days to respond, i was sick all weekend, didn't 
 get anywhere near my computer.

 i changed the names of the inputs from *listingsattrs*  
 *listings_attrs* as you recommended (no clue how i missed that to 
 begin with). My POST data now looks exactly as it did before, except for 
 the name of that particular item. However, the log output for the 
 $listing entity is still missing the associated ListingsAttrs data.

 The ListingsAttrs Entity didn't have a $_accessible array, so i added 
 a default:
 $_accessible = [
   '*' = true
 ];

 The controller code looks like:
 $listing = $this-Listings-newEntity($this-request-data);

 /* i've also tried:
 $listing = $this-Listings-newEntity($this-request-data, 
 ['associated' = ['ListingsAttrs']]);
 $listing = $this-Listings-newEntity($this-request-data, 
 ['associated' = ['ItemAttrs']]);
 $listing = $this-Listings-newEntity($this-request-data, 
 ['associated' = ['ListingsAttrs.ItemAttrs']]);
 $listing = $this-Listings-newEntity($this-request-data, 
 ['associated' = ['ItemAttrs.ListingsAttrs']]);
 */

 if ($this-Listings-save($listing)) {
   // etc.
 }
 else {
   throw new Exception...
 }

 What else can i try? i appreciate the help.
 -joe

 On Friday, 19 December 2014 11:29:12 UTC-5, José Lorenzo wrote:

 You should post a property called listings_attrs, check your entity 
 $_accessible array to make sure the property is also writable with 
 request 
 data.

 On Friday, December 19, 2014 6:29:43 AM UTC+1, Joe T. wrote:

 i've seen a couple similar threads about this, but not my exact 
 problem.

 i'm trying to follow the guide here: 
 http://book.cakephp.org/3.0/en/orm/saving-data.html#converting-request-data-into-entities
  
 and coming up short. *i'm not getting any errors* (except a date 
 field that constantly fails if it has a value, separate issue)...so i 
 have 
 no idea what's happening to the data i submit, or why it isn't saved to 
 the 
 DB.

 My raw response data logged to Cake Debug is:

 Array (
   [title] = '123 Main St'
   [street] = '123 Main St'
   [lot_no] = 1
   [lat] =
   [lng] =
   [city] = 'Hometown'
   [county] = 
   [state] = 'MI'
   [zip] = '49000'
   [area] = 900 
   [bedrooms] = 2 
   [bathrooms] = 1 
   [price] = 525 
   [ready_date] =
   [listingsattrs] = Array (
 [4] = Array (
   [id] = 4
 )
 [1] = Array (
   [id] = 1
   [value] = 'Off-street'
 )
   )
   [park_id] = 1
   [house_condition_id] = 3
   [house_style_id] = 2 
   [term_id] = 2
   [info_body] = 'pLive here. It#39;s great!/p'
 ) 

 i have tables *Listings*, *ItemAttrs*, and *ListingsAttrs*. In 
 *ListingsTable*, the relationship is defined as:
 $this-addAssociations([
   'belongsToMany' = [
 'ItemAttrs' = [
   'targetForeignKey' = 'attr_id',
   'through'  = 'ListingsAttrs',
   'saveStrategy' = 'replace',
   ]
 ])'

 *Some* attributes 

3.0 - Inflections

2015-01-13 Thread Leandro Machado Pereira
My friends, i try to customize my inflections for cake 3.0 rc1.

When i used cake 2.0 i used this:


// Plural to singular
Inflector::rules('singular', [
'rules' = [
'/^(.*)(oes|aes|aos)$/i' = '\1ao',
],
'irregular' = [
'panels' = 'panel',
'Requests' = 'Requests',
],
'uninflected' = []
]);

// Singular to plural
Inflector::rules('plural', [
'rules' = [
'/^(.*)ao$/i' = '\1oes',
],
'irregular' = [
'panel' = 'panels',
],
'uninflected' = []
]); 


In cake 3.0 i received this error.


*Trace error*

*Warning* (2): preg_match(): Delimiter must not be alphanumeric or backslash 
[*CORE/src/Utility/Inflector.php*, line *569*]
Code Context

$word = 'Requests'
$regs = []
$rule = 'rules'
$replacement = [
'/^(.*)(oes|aes|aos)$/i' = '\1ao'
]

preg_match - [internal], line ??
Cake\Utility\Inflector::singularize() - CORE/src/Utility/Inflector.php, line 569
Cake\ORM\Table::entityClass() - CORE/src/ORM/Table.php, line 493
Cake\ORM\Marshaller::one() - CORE/src/ORM/Marshaller.php, line 108
Cake\ORM\Table::newEntity() - CORE/src/ORM/Table.php, line 1829
DebugKit\Routing\Filter\DebugBarFilter::afterDispatch() - 
ROOT/plugins/DebugKit/src/Routing/Filter/DebugBarFilter.php, line 187
Cake\Event\EventManager::_callListener() - CORE/src/Event/EventManager.php, 
line 276
Cake\Event\EventManager::dispatch() - CORE/src/Event/EventManager.php, line 242
Cake\Routing\Dispatcher::dispatchEvent() - 
CORE/src/Event/EventManagerTrait.php, line 78
Cake\Routing\Dispatcher::dispatch() - CORE/src/Routing/Dispatcher.php, line 92
[main] - ROOT/webroot/index.php, line 37

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: 3.0 - Inflections

2015-01-13 Thread Leandro Machado Pereira
So, i found the answer, but i'm testing yet.

Inflector::rules('singular', ['/^(.*)(oes|aes|aos)$/i' = '\1ao',
'/^(.*)ao$/i' = '\1oes']);


Em Tue Jan 13 2015 at 10:30:55, Leandro Machado Pereira 
llperei...@gmail.com escreveu:

 My friends, i try to customize my inflections for cake 3.0 rc1.

 When i used cake 2.0 i used this:


 // Plural to singular
 Inflector::rules('singular', [
 'rules' = [
 '/^(.*)(oes|aes|aos)$/i' = '\1ao',
 ],
 'irregular' = [
 'panels' = 'panel',
 'Requests' = 'Requests',
 ],
 'uninflected' = []
 ]);

 // Singular to plural
 Inflector::rules('plural', [
 'rules' = [
 '/^(.*)ao$/i' = '\1oes',
 ],
 'irregular' = [
 'panel' = 'panels',
 ],
 'uninflected' = []
 ]);


 In cake 3.0 i received this error.


 *Trace error*

 *Warning* (2): preg_match(): Delimiter must not be alphanumeric or backslash 
 [*CORE/src/Utility/Inflector.php*, line *569*]
 Code Context

 $word = 'Requests'
 $regs = []
 $rule = 'rules'
 $replacement = [
   '/^(.*)(oes|aes|aos)$/i' = '\1ao'
 ]

 preg_match - [internal], line ??
 Cake\Utility\Inflector::singularize() - CORE/src/Utility/Inflector.php, line 
 569
 Cake\ORM\Table::entityClass() - CORE/src/ORM/Table.php, line 493
 Cake\ORM\Marshaller::one() - CORE/src/ORM/Marshaller.php, line 108
 Cake\ORM\Table::newEntity() - CORE/src/ORM/Table.php, line 1829
 DebugKit\Routing\Filter\DebugBarFilter::afterDispatch() - 
 ROOT/plugins/DebugKit/src/Routing/Filter/DebugBarFilter.php, line 187
 Cake\Event\EventManager::_callListener() - CORE/src/Event/EventManager.php, 
 line 276
 Cake\Event\EventManager::dispatch() - CORE/src/Event/EventManager.php, line 
 242
 Cake\Routing\Dispatcher::dispatchEvent() - 
 CORE/src/Event/EventManagerTrait.php, line 78
 Cake\Routing\Dispatcher::dispatch() - CORE/src/Routing/Dispatcher.php, line 92
 [main] - ROOT/webroot/index.php, line 37

  --
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP

 ---
 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to cake-php+unsubscr...@googlegroups.com.
 To post to this group, send email to cake-php@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php.
 For more options, visit https://groups.google.com/d/optout.


-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


What is MVC?

2015-01-13 Thread Gowthaman Suriya
Hi, friends. 

Anyone can explain about this clearly?. Why did they implement MVC concept 
in cakePHP?. 

Thanks for reply..

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


CakePHP 3: 2 Qs - Response From Filter Helper Constructor

2015-01-13 Thread Chris White
Hi all,

I'm porting a fairly sizable CakePHP 1.3 app to CakePHP 3 and have run into 
a couple of issues with which hopefully someone can help me out.

*Rejecting a Request from a Filter*

First, I'm trying to reject a request from a filter. I am setting the 
response's type to json and its status code to 403, but the app is still 
reporting 200. The code is:

$response = $event-data['response'];
$response-type('application/json');
$response-body(json_encode([ 'errors' = [ 'Invalid request to api' ] ]));
$response-statusCode(403);

$event-stopPropagation();

return $response;

Request, response, and status are:

Status 200 OK 

Request headers 

Accept: application/json
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/
537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8
Cookie: CAKEPHP=717f0482276fca1b0f3c3c7155923657

Response headers 

Date: Mon, 12 Jan 2015 23:30:33 GMT 
Server: Apache/2.2.29 (Unix) mod_fastcgi/2.4.6 mod_wsgi/3.4 Python/2.7.8 PHP
/5.6.2 mod_ssl/2.2.29 OpenSSL/0.9.8za DAV/2 mod_perl/2.0.8 Perl/v5.20.0 
X-Powered-By: PHP/5.6.2
Content-Length: 48 
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8 Response

{errors:[Invalid request to inventory_api]}


I'm guessing I'm somehow doing this wrong?

*Constructing a Helper*

Second, I have several helpers but they are failing to be constructed due 
to type issues. While I have been using PHP off and on for nearly 15 years 
(since version 3),  I am new to the namespacing found in the newest 
versions, so it may be related. Below is one example. I am adding to the 
helpers collection thusly in the AppController:

$this-helpers[] = 'NavBar';



The class constructor is defined as:

namespace MyNS\View\Helper;

use Cake\View\Helper;
use Cake\Core\Configure;

class MyHelper extends Helper {

public function __construct(\MyNS\View $view, $config=[]) {



The warning I am receiving is:

Argument 1 passed to MyNS\View\Helper\MyHelper::__construct() must be an 
instance of MyNS\View, instance of MyNS\View\AppView given


Thanks for any help you may be able to provide to either question!

Chris

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: What is MVC?

2015-01-13 Thread Tim Dunphy
MVC is a general programming concept, that applies to any and all
languages. It stands for Model View Controller.

Model is your data. And by this I'm referring to a database like MySQL,
MongoDB, CassandraDB etc.

View is your presentation layer. What the user actually sees in his or her
web browser. Consisting of the visual elements the user sees and the
surface level controls usually generated by things like java script.

Controller is the intelligence built into your program. It consists of the
code generated by your core programming language. Be it, PHP, Ruby, Java,
nodeJS or any other programming language you might want to use.

It's a general way of thinking about how to organize your website and think
about it logically.

You may find more information about that here:

http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller

And googling Model View Controller certainly couldn't hurt! ;)

Tim

On Tue, Jan 13, 2015 at 6:11 AM, Gowthaman Suriya 
gowthaman.sur...@gmail.com wrote:

 Hi, friends.

 Anyone can explain about this clearly?. Why did they implement MVC concept
 in cakePHP?.

 Thanks for reply..

 --
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP

 ---
 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to cake-php+unsubscr...@googlegroups.com.
 To post to this group, send email to cake-php@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php.
 For more options, visit https://groups.google.com/d/optout.




-- 
GPG me!!

gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: CakePHP 3: 2 Qs - Response From Filter Helper Constructor

2015-01-13 Thread José Lorenzo
You are setting this message:
$response-body(json_encode([ 'errors' = [ 'Invalid request to api' ] ]));

But getting this error:

{errors:[Invalid request to inventory_api]}

That makes me think that you are setting the response from somewhere else, 
and not where you think.

In your custom helper you would do:

 public function __construct(\MyNS\View\AppView $view, $config=[]) {

And that should fix it!

On Tuesday, January 13, 2015 at 3:45:41 PM UTC+1, Chris White wrote:

 Hi all,

 I'm porting a fairly sizable CakePHP 1.3 app to CakePHP 3 and have run 
 into a couple of issues with which hopefully someone can help me out.

 *Rejecting a Request from a Filter*

 First, I'm trying to reject a request from a filter. I am setting the 
 response's type to json and its status code to 403, but the app is still 
 reporting 200. The code is:

 $response = $event-data['response'];
 $response-type('application/json');
 $response-body(json_encode([ 'errors' = [ 'Invalid request to api' ] 
 ]));
 $response-statusCode(403);

 $event-stopPropagation();
 
 return $response;

 Request, response, and status are:

 Status 200 OK 

 Request headers 

 Accept: application/json
 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/
 537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36
 Accept-Encoding: gzip, deflate, sdch
 Accept-Language: en-US,en;q=0.8
 Cookie: CAKEPHP=717f0482276fca1b0f3c3c7155923657

 Response headers 

 Date: Mon, 12 Jan 2015 23:30:33 GMT 
 Server: Apache/2.2.29 (Unix) mod_fastcgi/2.4.6 mod_wsgi/3.4 Python/2.7.8 
 PHP/5.6.2 mod_ssl/2.2.29 OpenSSL/0.9.8za DAV/2 mod_perl/2.0.8 Perl/v5.20.0 
 X-Powered-By: PHP/5.6.2
 Content-Length: 48 
 Keep-Alive: timeout=5, max=100
 Connection: Keep-Alive
 Content-Type: text/html; charset=UTF-8 Response

 {errors:[Invalid request to inventory_api]}


 I'm guessing I'm somehow doing this wrong?

 *Constructing a Helper*

 Second, I have several helpers but they are failing to be constructed due 
 to type issues. While I have been using PHP off and on for nearly 15 years 
 (since version 3),  I am new to the namespacing found in the newest 
 versions, so it may be related. Below is one example. I am adding to the 
 helpers collection thusly in the AppController:

 $this-helpers[] = 'NavBar';



 The class constructor is defined as:

 namespace MyNS\View\Helper;

 use Cake\View\Helper;
 use Cake\Core\Configure;

 class MyHelper extends Helper {
 
 public function __construct(\MyNS\View $view, $config=[]) {



 The warning I am receiving is:

 Argument 1 passed to MyNS\View\Helper\MyHelper::__construct() must be an 
 instance of MyNS\View, instance of MyNS\View\AppView given


 Thanks for any help you may be able to provide to either question!

 Chris



-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: CakePHP 3: 2 Qs - Response From Filter Helper Constructor

2015-01-13 Thread Chris White
José,

Thank you! Simple enough; I should have tried that.

Still not sure about the filter response issue for anyone else reading.

Chris

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: CakePHP 3: 2 Qs - Response From Filter Helper Constructor

2015-01-13 Thread Chris White
Oh, and that was a simple anonymization error on my part in the post. The 
response data is fine.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.