Re: What's the correct method for using Traits and Namespaces for CakePHP 2?

2014-01-27 Thread Reuben
For the moment, even though PHP 5.5 has namespaces, it just seems to work 
if you don't use them (namespaces, that is).

You will need to have an App::uses() statement to use load the trait, and 
you'll also need the 'use' statement in the class.

And given that namespaces are not in use, also keep 'app' as 'app' and not 
'App'.  Although replacing 'app' with APP_DIR would be better for CakePHP 
2.4.5 projects that have selected a different name for their project, and 
don't have the HTTP root pointing to webroot (in the case of integration 
with legacy apps).

Regards
Reuben Helms

On Tuesday, 28 January 2014 10:52:07 UTC+10, Reuben wrote:
>
> My original question on Stack Overflow [
> http://stackoverflow.com/questions/21394852/whats-the-correct-method-for-using-traits-and-namespaces-for-cakephp-2],
>  
> and content copied here, should that disappear.
>
> I'm using CakePHP 2.4.5 and PHP 5.5, and would like to use a trait.
>
> I have a trait in Utility/VariablesTrait.php called VariablesTrait.
>
> To take advantage of namespaces, I've given it a namespace of 
> App\Utility\VariablesTrait, since Utility\VariablesTrait seems a bit too 
> global, and the former would work better with CakePHP 3.
>
> In my class that I want to use it in, I have the use 
> App\Utility\VariablesTrait; statement in the class. For backup, I also 
> have a App::uses('VariablesTrait', 'Utility'); statement at the top of 
> the file. I'm not sure if the SPL autoloader is used when looking for 
> traits, which is why I was going for namespaces in the first place.
>
> The small issue is that the app directory is app, and since directory 
> structures should match namespaces (I think), I renamed it to App. 
> However, CakeRequest::_base() hardcodes app, so determining the 
> controller doesn't work so well.
>
> So, I'm trying to determine if that's a CakePHP bug, or if there is a more 
> appropriate way of using traits in CakePHP 2.
>
>
> Regards
>
> Reuben Helms
>

-- 
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/groups/opt_out.


What's the correct method for using Traits and Namespaces for CakePHP 2?

2014-01-27 Thread Reuben
My original question on Stack Overflow 
[http://stackoverflow.com/questions/21394852/whats-the-correct-method-for-using-traits-and-namespaces-for-cakephp-2],
 
and content copied here, should that disappear.

I'm using CakePHP 2.4.5 and PHP 5.5, and would like to use a trait.

I have a trait in Utility/VariablesTrait.php called VariablesTrait.

To take advantage of namespaces, I've given it a namespace of 
App\Utility\VariablesTrait, since Utility\VariablesTrait seems a bit too 
global, and the former would work better with CakePHP 3.

In my class that I want to use it in, I have the use 
App\Utility\VariablesTrait; statement in the class. For backup, I also have 
a App::uses('VariablesTrait', 'Utility'); statement at the top of the file. 
I'm not sure if the SPL autoloader is used when looking for traits, which 
is why I was going for namespaces in the first place.

The small issue is that the app directory is app, and since directory 
structures should match namespaces (I think), I renamed it to App. However, 
CakeRequest::_base() hardcodes app, so determining the controller doesn't 
work so well.

So, I'm trying to determine if that's a CakePHP bug, or if there is a more 
appropriate way of using traits in CakePHP 2.


Regards

Reuben Helms

-- 
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/groups/opt_out.


Re: cakephp 1.3.10 - URL rewriting is not properly configured on your server

2014-01-27 Thread Vikash Sharma

>
> plz uncomment rewrite in apache config file .. 

-- 
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/groups/opt_out.


Ajuda com AuthComponent

2014-01-27 Thread Vinicius Souza
Hello everyone, I'm having trouble with the authentication system, the 
scenario is as follows: 
I have a database with two tables (Users and Posts) Posts in have a user-id 
field. 

My PostsController.php with add () function 
   set('posts', $this->Post->find('all'));
  }

  public function adicionar()
  {
 if($this->request->is('post'))
 {
if($this->Post->saveAll($this->request->data))
{
   $this->Session->setFlash('O post foi adicionado com 
sucesso!');
   $this->redirect(array('action' => 'index'));
} else {
   $this->Session->setFlash('O post não foi adicionado. Tente 
novamente!');
}
 }
  }


And adicionar.ctp 
  
Form->create('Post'); ?>

Adicionar
Form->input('title');
echo $this->Form->input('body');
?>

Form->end('CRIAR POST'); ?>


Actions

Html->link('Listar', array('action' => 'index')); 
?>




The problem is that the bank is not slavando logged the user who created 
the post, tried using the hasOne model but had no luck. 

Can you help me?

-- 
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/groups/opt_out.


3.0 FormHelper branch?

2014-01-27 Thread RobertM
Is there any public branch where can we see how new FormHelper will be 
implemented?
Would love to play with 3.0's little more ...

R

-- 
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/groups/opt_out.


Re: Cake console shell error - not able to see App

2014-01-27 Thread Nif
OK... it was me. All me. I was missing a semi-colon ;p

I do however have a new issue. I manage to call in my Component, but that 
component calls one of my controllers and this is now throwing an error 
when running in the console. I need all the functionality to be accessible 
to both the web based app and to the console as there is a manual call to 
this component and there is a cron job which will run the shell script 
every hour or so, which in turn is calling my component.

Is there a better way to do this, baring in mind that the app is pretty 
much complete and I'd be in a big pickle if I had to drastically change the 
structure of any of it. The cron job is an add on.

Thanks in advance,
Nikki

-- 
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/groups/opt_out.


Rendering PDF from POST basead searches

2014-01-27 Thread Nilson Pena
Hi folks,
I use mPDF and the solution proposed in this excellent post [1]. Everything
works well if the action uses GET. Example: /controller/action/2.pdf wil
use the view.ctp inside the pdf folder and render the 2.pdf file.

But there are cases that I have to use a form to POST some parameters to do
a especific search and return this data to the view. In this case, the
/controller/action/2.pdf won't work, once the action only allows POST.

How can I workaround this "issue" and keep using this approach on serving
PDF?

Thank You!

Nilson

[1] http://www.dereuromark.de/2011/11/21/serving-views-as-files-in-cake2/

-- 
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/groups/opt_out.


Cake console shell error - not able to see App

2014-01-27 Thread Nif
Hi All,

I am new to the cake console and especially to creating a shell to run 
in/on it. The research I have done says it should be possible to call App 
from the shell and the examples I have seen use code like the below to do 
so.

out("Processing...\n");
$collection = new ComponentCollection();
$this->MMail = new ManageMailComponent($collection);
$controller = new Controller();
$this->MMail->initialize($controller);

$this->MMail->doMailCall();
$this->out("Complete\n");
}
}
?>

But, when I run this I get a syntax error stating: unexpected 'App' 
(T_STRING) in 

Or, if I try this other suggested method (sorry, can't remember where I 
found this as a suggested method):

out('Hello world.');
}
}
?>

Then I get this error:
Fatal error: Class 'AppModel' not found in 
\lib\Cake\Utility\ClassRegistry.php

And here is some more possibly relevant fun info:

There are 2 Console folders - app/Console and lib/Cake/Console - I am sure 
this is correct, but on mine, no matter where I run the cake.bat file it 
always calls the lib/Cake/Console/Command folder for the shell file and 
never the app/Console/Command folder. Not sure if this is at all relelvant, 
but thought it would be worth mentioning. - Yes, I do have path environment 
variable set and have tried pointing at each directory in turn.

I also had to copy the cake.bat file from a new zipped version of cake into 
the two Console folders as my copy did not have it. Not sure why, but think 
it might have been version control related or something along those lines. 
Anyway, there may have been a slight adjustment in the version of Cake 
(mayby a .1 or .2) but I'm not sure as my origional files were on an old 
machine and not accessible, so I couldn't compare versions (I am sure there 
is a way to check in the files themselves, but I am lame and couldn't 
figure it out).
So I do know the project is cakephp 2.something at least, but there is a 
chance that my cake.bat file is from a very slightly newer version.

That's pretty much it.
Has anyone had this issue?
Has anyone successfully called their App from a shell file?
Am I being a complete moron? (Occam's Razor favours this answer)

Thanks in advance,
Nikki

-- 
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/groups/opt_out.