Re: I'm coming from Rails 3.2. There are some specific things I'd know how to do in CakePHP 2.0. Can someone help me?

2012-06-14 Thread Bruno Dias
Thank you Randy! Surely I'll take a look on these suggestions.

On Jun 6, 3:46 pm, randy ses...@gmail.com wrote:
 Hey Bruno,

 I can answer some of these with some of my experience. I don't have much
 experience in Rails but I try to keep up with what's happening in that camp.

 Packages: Personally, for plugins and libs, I use git submodules. There are
 pitfalls there, but it works and since I'm the only one that owns the code,
 I just work through them.

 Migrations: I believe Cake supports migrations but have not used them much.
 I believe it works similar to Rails.

 Automated Deploys: I've read that people use Cap for PHP deployments. Cap
 seems pretty flexible and can be used outside the Rails domain. There's
 also things like ant and Phing but haven't looked into this just yet (but
 seriously need to)

 Asset Compression: Yes. Via plugin written Mark Story 
 (https://github.com/markstory/asset_compress) It works pretty well and
 supports CDNs. Also supports things like coffee script and lesscss.

 Workers, etc: Cake has a Task/Shell framework that allows you create, well,
 tasks and shell programs you can run from cron or wherever. Beyond that,
 you can add event handlers/listeners to respond to custom events in Cake's
 Event system (http://book.cakephp.org/2.0/en/core-libraries/events.html)
 which is new in 2.1. Then there's things like Gearman and Beanstalkd
 (neither of which I have exposure to but the concept sounds interesting)

 Skipping some points...  Testing: PHPUnit is the framework used by CakePHP
 2+http://book.cakephp.org/2.0/en/development/testing.html

 Like you said, there's many ways to skin a cat, but these are some off the
 top of my head.

 Cheers!
 randy







 On Wed, Jun 6, 2012 at 8:19 AM, Bruno Dias bruno...@gmail.com wrote:
  Hi guys. My intention is not to make comparisons or discuss which
  framework is better. I know the power from both CakePHP and Rails. I'm
  sure that there's a way to do similar things in both of them.

  So, this is the situation: in Rails framework, I'm used to do
  somethings that I'd like to do on CakePHP (some of them I haven't
  found on the documentation).

  They are:

  - Package management
  In Rails, I have the Gemfile file, where I write the version of each
  gem used in the application. If I want to upgrade or downgrade, I
  change the version and run the bundle update command. How do you
  update plugins? Do you use tools like GIT to checkout each one to
  newer versions?

  - Migrations
  When I need to change the database, I create a empty migration file
  through the console command rails generate migration. Then, in the
  generated file, I add the changes, like
  rename_column :users, :address, :location. After that, I run rake
  db:migrate and the database is migrated. How to do that on CakePHP?

  - Automated Deployment
  Deployment in Rails can be made automated using the Capistrano ruby
  gem. Basically, I run cap production deploy in the command line.
  Then, based on the instructions on the deploy.rb file, it logs into
  the server(s), clone the newest version of the code from the git
  repository, and backups the current release, so I can rollback. It
  also can create symlinks for shared folders (like user uploads),
  recompile the assets, run pending migrations, install new
  dependencies, restart some server processes, restart the application
  itself, and can execute other command line tasks. Is there something
  similar on CakePHP?

  - Assets compression
  In Rails, when I'm in production mode, the CSS and JS assets are
  automatically compiled into single files, and regenerated after each
  deployment. That's a native feature in Rails 3.1+. Is that possible on
  CakePHP?

  - Workers and Background Jobs
  Rails can use a gem called delayed_job to enqueue tasks to be
  executed in background by workers, like sending an e-mail after user
  signup, for example. How do you do that?

  - Namespaces for controllers
  If I want to create an admin interface, or a web service (using the
  api namespace, for example), or a mobile namespace, I just create
  the respective folders on the controllers folder. Then, I put the
  controllers there and create the routes to access them. What's the
  best way to do that on Cake?

  - Access model methods from view
  It seems that CakePHP return an associative array when I grab data
  from the database, and not the true objects. So, I can not access
  the model methods.
  Let's suppose my UserModel class provides a method called age that
  calculates the user current age based on his birthday. In Rails, I
  could do this on the view: %= @user.age %. I need to create a view
  helper for doing that on Cake? Like ?php $helpers-
  calc_user_age($user); ? (or something like that) ?
  Another situation: Let's suppose I want to get the last comment from a
  user, and within the comment, insert a link to the related post using
  the post title.
  In Rails I would do something like 

Re: I'm coming from Rails 3.2. There are some specific things I'd know how to do in CakePHP 2.0. Can someone help me?

2012-06-14 Thread Bruno Dias
Hi stork! Thanks for your feedback. I'll take a look!

On Jun 6, 6:01 pm, stork lubomir.st...@gmail.com wrote:
 One more thing about migrations - yes, CakePHP does have builtin shell for
 database schema 
 dump/restorehttp://book.cakephp.org/2.0/en/console-and-shells/schema-management-a...
 but mentioned CakeDC migrations plugin is better.

 And - welcome in CakePHP community! :-)

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


I'm coming from Rails 3.2. There are some specific things I'd know how to do in CakePHP 2.0. Can someone help me?

2012-06-06 Thread Bruno Dias
Hi guys. My intention is not to make comparisons or discuss which
framework is better. I know the power from both CakePHP and Rails. I'm
sure that there's a way to do similar things in both of them.

So, this is the situation: in Rails framework, I'm used to do
somethings that I'd like to do on CakePHP (some of them I haven't
found on the documentation).

They are:

- Package management
In Rails, I have the Gemfile file, where I write the version of each
gem used in the application. If I want to upgrade or downgrade, I
change the version and run the bundle update command. How do you
update plugins? Do you use tools like GIT to checkout each one to
newer versions?

- Migrations
When I need to change the database, I create a empty migration file
through the console command rails generate migration. Then, in the
generated file, I add the changes, like
rename_column :users, :address, :location. After that, I run rake
db:migrate and the database is migrated. How to do that on CakePHP?

- Automated Deployment
Deployment in Rails can be made automated using the Capistrano ruby
gem. Basically, I run cap production deploy in the command line.
Then, based on the instructions on the deploy.rb file, it logs into
the server(s), clone the newest version of the code from the git
repository, and backups the current release, so I can rollback. It
also can create symlinks for shared folders (like user uploads),
recompile the assets, run pending migrations, install new
dependencies, restart some server processes, restart the application
itself, and can execute other command line tasks. Is there something
similar on CakePHP?

- Assets compression
In Rails, when I'm in production mode, the CSS and JS assets are
automatically compiled into single files, and regenerated after each
deployment. That's a native feature in Rails 3.1+. Is that possible on
CakePHP?

- Workers and Background Jobs
Rails can use a gem called delayed_job to enqueue tasks to be
executed in background by workers, like sending an e-mail after user
signup, for example. How do you do that?

- Namespaces for controllers
If I want to create an admin interface, or a web service (using the
api namespace, for example), or a mobile namespace, I just create
the respective folders on the controllers folder. Then, I put the
controllers there and create the routes to access them. What's the
best way to do that on Cake?

- Access model methods from view
It seems that CakePHP return an associative array when I grab data
from the database, and not the true objects. So, I can not access
the model methods.
Let's suppose my UserModel class provides a method called age that
calculates the user current age based on his birthday. In Rails, I
could do this on the view: %= @user.age %. I need to create a view
helper for doing that on Cake? Like ?php $helpers-
calc_user_age($user); ? (or something like that) ?
Another situation: Let's suppose I want to get the last comment from a
user, and within the comment, insert a link to the related post using
the post title.
In Rails I would do something like @user.comments.last.post.title to
get the post title. How could I do that in Cake, without using that
recursive=3 feature that gets lots of unnecessary data?

- Chaining model scopes
Let's suppose I have a model called Post. In Rails, I can create
scopes on models and mix them the way I want.
If I want to the get the 5 last published posts from the category
Programming ordered by the most accessed, for example, I would call
them this way:
Post.published.from_category(programming).most_accessed.limit(5).
If I want only the draft posts ordered by recent, integrated with
pagination, I would call Post.drafts.recent.page(2).
What is the best way to create and chain scopes on CakePHP? Build
dynamically an array of conditions and send it as the parameter for
find?

- Tests
What are the testing tools adopted by the CakePHP community? I need to
test the models and its methods, test the controllers and its
responses and variables, and test the views content (also Javascript
interaction), create fixtures, etc. I also would know if there is a
way to create something like autotest, that run the tests after file
saves.

Well, basically these are the points. Sorry for the long post, and for
my error-prone and redundant english (i'm not a native speaker). Hope
we can have a good conversation. Thank you!

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: I'm coming from Rails 3.2. There are some specific things I'd know how to do in CakePHP 2.0. Can someone help me?

2012-06-06 Thread randy
Hey Bruno,


I can answer some of these with some of my experience. I don't have much
experience in Rails but I try to keep up with what's happening in that camp.

Packages: Personally, for plugins and libs, I use git submodules. There are
pitfalls there, but it works and since I'm the only one that owns the code,
I just work through them.

Migrations: I believe Cake supports migrations but have not used them much.
I believe it works similar to Rails.

Automated Deploys: I've read that people use Cap for PHP deployments. Cap
seems pretty flexible and can be used outside the Rails domain. There's
also things like ant and Phing but haven't looked into this just yet (but
seriously need to)

Asset Compression: Yes. Via plugin written Mark Story (
https://github.com/markstory/asset_compress) It works pretty well and
supports CDNs. Also supports things like coffee script and lesscss.

Workers, etc: Cake has a Task/Shell framework that allows you create, well,
tasks and shell programs you can run from cron or wherever. Beyond that,
you can add event handlers/listeners to respond to custom events in Cake's
Event system (http://book.cakephp.org/2.0/en/core-libraries/events.html)
which is new in 2.1. Then there's things like Gearman and Beanstalkd
(neither of which I have exposure to but the concept sounds interesting)

Skipping some points...  Testing: PHPUnit is the framework used by CakePHP
2+
http://book.cakephp.org/2.0/en/development/testing.html

Like you said, there's many ways to skin a cat, but these are some off the
top of my head.

Cheers!
randy



On Wed, Jun 6, 2012 at 8:19 AM, Bruno Dias bruno...@gmail.com wrote:

 Hi guys. My intention is not to make comparisons or discuss which
 framework is better. I know the power from both CakePHP and Rails. I'm
 sure that there's a way to do similar things in both of them.

 So, this is the situation: in Rails framework, I'm used to do
 somethings that I'd like to do on CakePHP (some of them I haven't
 found on the documentation).

 They are:

 - Package management
 In Rails, I have the Gemfile file, where I write the version of each
 gem used in the application. If I want to upgrade or downgrade, I
 change the version and run the bundle update command. How do you
 update plugins? Do you use tools like GIT to checkout each one to
 newer versions?

 - Migrations
 When I need to change the database, I create a empty migration file
 through the console command rails generate migration. Then, in the
 generated file, I add the changes, like
 rename_column :users, :address, :location. After that, I run rake
 db:migrate and the database is migrated. How to do that on CakePHP?

 - Automated Deployment
 Deployment in Rails can be made automated using the Capistrano ruby
 gem. Basically, I run cap production deploy in the command line.
 Then, based on the instructions on the deploy.rb file, it logs into
 the server(s), clone the newest version of the code from the git
 repository, and backups the current release, so I can rollback. It
 also can create symlinks for shared folders (like user uploads),
 recompile the assets, run pending migrations, install new
 dependencies, restart some server processes, restart the application
 itself, and can execute other command line tasks. Is there something
 similar on CakePHP?

 - Assets compression
 In Rails, when I'm in production mode, the CSS and JS assets are
 automatically compiled into single files, and regenerated after each
 deployment. That's a native feature in Rails 3.1+. Is that possible on
 CakePHP?

 - Workers and Background Jobs
 Rails can use a gem called delayed_job to enqueue tasks to be
 executed in background by workers, like sending an e-mail after user
 signup, for example. How do you do that?

 - Namespaces for controllers
 If I want to create an admin interface, or a web service (using the
 api namespace, for example), or a mobile namespace, I just create
 the respective folders on the controllers folder. Then, I put the
 controllers there and create the routes to access them. What's the
 best way to do that on Cake?

 - Access model methods from view
 It seems that CakePHP return an associative array when I grab data
 from the database, and not the true objects. So, I can not access
 the model methods.
 Let's suppose my UserModel class provides a method called age that
 calculates the user current age based on his birthday. In Rails, I
 could do this on the view: %= @user.age %. I need to create a view
 helper for doing that on Cake? Like ?php $helpers-
 calc_user_age($user); ? (or something like that) ?
 Another situation: Let's suppose I want to get the last comment from a
 user, and within the comment, insert a link to the related post using
 the post title.
 In Rails I would do something like @user.comments.last.post.title to
 get the post title. How could I do that in Cake, without using that
 recursive=3 feature that gets lots of unnecessary data?

 - Chaining model scopes
 Let's suppose I have a model 

Re: I'm coming from Rails 3.2. There are some specific things I'd know how to do in CakePHP 2.0. Can someone help me?

2012-06-06 Thread stork
- Package management - for libs/vendors/plugins - git submodules

- Migrations - mainly for database schema/content changes, but also for 
filesystem changes dependent on application version (migration does have 
before() and after() callbacks) - https://github.com/CakeDC/migrations

- Automated Deployment - whatever is required (Capistrano, Ant, make...), 
but I prefer pure git  console shells/tasks executed from git hooks

- Assets compression  - https://github.com/markstory/asset_compress

- Workers and Background Jobs - 
http://book.cakephp.org/2.0/en/console-and-shells.html

- Namespaces for controllers - 
http://book.cakephp.org/2.0/en/development/routing.html#prefix-routing

- Access model methods from view - combination of helpers, 
http://book.cakephp.org/2.0/en/models/retrieving-your-data.html#creating-custom-find-types
 
and http://book.cakephp.org/2.0/en/models/virtual-fields.html
I prefer to not call models from views/elements/layouts/helpers, but it is 
easy to obtain model instance from  ClassRegistry anywhere in application 
code.

- Chaining model scopes - either build $options (conditions, fields, order, 
recursive, contains...) dynamically, or custom find() type

- Tests - http://book.cakephp.org/2.0/en/development/testing.html - mostly 
through web interface, sometimes also from git hooks and TestShell 
http://book.cakephp.org/2.0/en/development/testing.html#running-tests-from-command-line

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: I'm coming from Rails 3.2. There are some specific things I'd know how to do in CakePHP 2.0. Can someone help me?

2012-06-06 Thread stork
One more thing about migrations - yes, CakePHP does have builtin shell for 
database schema dump/restore 
http://book.cakephp.org/2.0/en/console-and-shells/schema-management-and-migrations.html
 
but mentioned CakeDC migrations plugin is better.

And - welcome in CakePHP community! :-)

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Can someone help?

2007-02-07 Thread [EMAIL PROTECTED]

Maybe I am just missing something or being dumb, but could someone
take a look at this.
Here is a snippet of my code:

class NewsitemsController extends AppController {

var $name = 'Newsitems';
var $uses = array('Newsitem','User');
var $messages = array();

function index(){
addMessage(test);
//print_r($this-messages); //This prints 0-'test' as
expected
$this-set('msgs', $this-requestAction('/Newsitems/
msgrender',array('return')));
}

function addMessage($msg) {
$this-messages = array_merge($this-messages, array($msg));
}

function msgrender() {
$this-set('messages',$this-messages);
//print_r($this-messages); //This is empty!!!?
unset($this-messages);
$this-render();
}
}
?
-
index.thml
?
echo $msgs
?

msgrender.thtml
?
foreach($messages as $message) {
echo -.$message.-;
}
?

---
when I run this index is blank.

What am I doing wrong, it looks like it should work to me...


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Can someone help?

2007-02-07 Thread nate

First of all, you need to kick up your error level so you can see
something.  Usually this can be accomplished by setting DEBUG to 1 or
2 in /app/config/core.php.

Second, addMessage(test); should be $this-addMessage(test);

Third, $this-requestAction('/Newsitems/msgrender',array('return'))
should be $this-requestAction('/newsitems/msgrender',array('return'))
(note the case).

Fourth: in the future, if you're trying to get help on this list, it
helps to post with a title slightly less generic than Can someone
help?.

[EMAIL PROTECTED] wrote:
 Maybe I am just missing something or being dumb, but could someone
 take a look at this.
 Here is a snippet of my code:

 class NewsitemsController extends AppController {

 var $name = 'Newsitems';
 var $uses = array('Newsitem','User');
 var $messages = array();

 function index(){
 addMessage(test);
 //print_r($this-messages); //This prints 0-'test' as
 expected
 $this-set('msgs', $this-requestAction('/Newsitems/
 msgrender',array('return')));
 }

 function addMessage($msg) {
 $this-messages = array_merge($this-messages, array($msg));
 }

 function msgrender() {
 $this-set('messages',$this-messages);
 //print_r($this-messages); //This is empty!!!?
 unset($this-messages);
 $this-render();
 }
 }
 ?
 -
 index.thml
 ?
 echo $msgs
 ?
 
 msgrender.thtml
 ?
 foreach($messages as $message) {
 echo -.$message.-;
 }
 ?

 ---
 when I run this index is blank.

 What am I doing wrong, it looks like it should work to me...


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Can someone help?

2007-02-07 Thread [EMAIL PROTECTED]

I do have debug on, I didn't paste all my code I rewrote the most
important parts for this post.

So assuming that this code doesn't give me any errors because of my
typos, it still doesn't accomplish what I want it to.

Sorry for the vague title, I couldn't think of anything more
informative.

On Feb 7, 3:37 pm, nate [EMAIL PROTECTED] wrote:
 First of all, you need to kick up your error level so you can see
 something.  Usually this can be accomplished by setting DEBUG to 1 or
 2 in /app/config/core.php.

 Second, addMessage(test); should be $this-addMessage(test);

 Third, $this-requestAction('/Newsitems/msgrender',array('return'))
 should be $this-requestAction('/newsitems/msgrender',array('return'))
 (note the case).

 Fourth: in the future, if you're trying to get help on this list, it
 helps to post with a title slightly less generic than Can someone
 help?.



 [EMAIL PROTECTED] wrote:
  Maybe I am just missing something or being dumb, but could someone
  take a look at this.
  Here is a snippet of my code:

  class NewsitemsController extends AppController {

  var $name = 'Newsitems';
  var $uses = array('Newsitem','User');
  var $messages = array();

  function index(){
  addMessage(test);
  //print_r($this-messages); //This prints 0-'test' as
  expected
  $this-set('msgs', $this-requestAction('/Newsitems/
  msgrender',array('return')));
  }

  function addMessage($msg) {
  $this-messages = array_merge($this-messages, array($msg));
  }

  function msgrender() {
  $this-set('messages',$this-messages);
  //print_r($this-messages); //This is empty!!!?
  unset($this-messages);
  $this-render();
  }
  }
  ?
  -
  index.thml
  ?
  echo $msgs
  ?
  
  msgrender.thtml
  ?
  foreach($messages as $message) {
  echo -.$message.-;
  }
  ?

  ---
  when I run this index is blank.

  What am I doing wrong, it looks like it should work to me...- Hide quoted 
  text -

 - Show quoted text -


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---