开发者

What is a logical way to learn PHP for Drupal and WordPress coming from Ruby on Rails?

开发者 https://www.devze.com 2023-01-24 00:42 出处:网络
I\'m a self-taught hacker who\'s still not great but I can get simple crud apps working with Rails and I appreciate the beautiful design of Ruby. Ruby was my first programming language.

I'm a self-taught hacker who's still not great but I can get simple crud apps working with Rails and I appreciate the beautiful design of Ruby. Ruby was my first programming language.

Now I'm getting into Drupal and WordPress and starting to want to develop my own modules and plugins. But when I look at PHP it looks daunting--probably because Ruby has spoiled me.

All that said, I do want to try to pick up enough PHP to work with modules/plugins. Other than constructs like datatypes, operators, variables, etc. What high-level concepts do I need to know? I've been indoctrinated to OOP and MVC--will this hinder my PHP learning?

I've seen many books on 'Rails for PHP developers' but I've seen little about going the other way. I'd appreciate some logical task开发者_运维百科s or goals for an 'advanced' novice in web development.

Thank you.


What is your goal?

If you really want to learn PHP, I think you should stay away from Wordpress and Drupal for a while and start with a basic tutorial like http://php.net/manual/en/tutorial.php or http://www.tizag.com/phpT/.

If your goal is to learn Drupal and/or Wordpress, then I wouldn't focus on the php part (yet). I'm not a Wordpress expert, but for Drupal I advise you to learn what Drupal has to offer without any coding. I read a quote today saying "Drupal is oriented for sitebuilding first, coding later." I think that's spot on. I have seen experienced programmers who install Drupal core and start hacking around it instead of working with it. Once you have learned the site building and configuration part, start working on your php skills to add the small bits and pieces you're still missing.


I'd start off with creating a few themes for wordpress. Don't waste too much time on the design, just focus on how to get it running. Really focus on "the loop". It's a simple concept that is the basis of wordpress and will show you how straight forward php is.

Drupal is big. It will confuse and slow you down in terms of learning php.

I started with http://devzone.zend.com/node/view/id/625

Get the basics of php down, learn the loop, develop themes then maybe move onto drupal.


There is not really any high level concepts in PHP you can learn. Closures became available just recently, but that is about as advanced as it gets.

You already know MVC and OOP, which are used in some frameworks (CakePHP, Joomla). Wordpress, however is not well organized and clean. I don't know about drupal, though.

I think CakePHP is the most Rails-like PHP framework. The tutorials in the manual are quite good, so you might want to read through them to see how PHP can look in an OOP, MVC environment where you feel at home.

http://book.cakephp.org/view/1528/Blog


Drupal might not be the very best place to get started.

First: The php manual is also an invaluable resource: http://www.php.net/manual/en/ and you might be best served by going through the "getting started" section: http://www.php.net/manual/en/getting-started.php

I would breeze through that very quickly just to get a feel for things.

Once you've gotten the basics, I would move on to picking a framework for the next step:

There are tonnes of MVC frameworks out there. This thread discusses frameworks that are similar to Rails: https://stackoverflow.com/questions/117406/which-php-framework-is-closest-to-ruby-on-rails-cakephp-codeigniter

There is also PHP on Trax, which should be similar to Rails: http://wiki.phpontrax.com/index.php/Main_Page

If I were you I would pick a framework similar to what you are used and go through the accompanying tutorial.

Once you are more comfortable with PHP, you can start looking into some of the Drupal tutorials; for example: http://drupal.org/node/206753 (Creating modules - a tutorial: Drupal 6.x)

Finally: don't be afraid to take what you have learnt from Rails and apply it to your PHP. PHP is a pretty loose language which lets you write as good or as bad code as you like. Knowing language like Rails or Python should benefit your PHP a good deal.

For example: http://www.oreillynet.com/ruby/blog/2007/09/7_reasons_i_switched_back_to_p_1.html


No ruby programmer will ever need an in depth PHP introduction. Ruby is - beneath the surface - much more complex.

To get started:

  • setup a default apache
  • put a index.php into docroot
  • put
  • start writing a small blog application (embrace spaghetti code here[info])
  • start to refactor it into a small MVC style app

For online help: The PHP.net manual is very good. You will have a hard time to find things that are not covered by it, while you learn PHP.

You wonder about PHP OOP? You will be kinda disappointed that there's not much to learn (in contrast to ruby).

[info] You can argue that it's probably a bad idea to tell anyone something like that. But it's the way PHP works and you should know your tools in every way.

PS: Stay away from globals. PPS: Use PHP as template engine.


From a Drupal POV, the following document, while dated, will prove illuminating: http://drupal.org/node/547518

For the OP, the above might be overkill until he/she gets familiar with Drupal. Nevertheless, it is a good read.

0

精彩评论

暂无评论...
验证码 换一张
取 消