Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Currently, I'm very comfortable with building tools/web apps in an ASP.NET environment. I'm not really looking to leave tbh, as I really like C#, ASP.NET, MVC 3, Visual Studio, etc.

However, right now I know almost nothing about PHP and that seems like a deficiency that I'd like to rectify.

Are there any books (or other learning methods) that would be a good resource to learn PHP? Obviously there are plenty of beginning PHP books, but I am already comfortable with much of what is involved with building a web page, and interested in focusing on PHP itself which might not be compatible with the scope of some beginning PHP books.

I went through the PHP Manual quite a bit, and it doesn't seem to flow as smoothly as might be ideal. Is there a beginning PHP book that would be appropriate? I miss the cohesiveness that most books contain when looking through those samples. There is lots of info more, but it feels more like a reference while coding than a primary learning vehicle.

share|improve this question
5  
Why do you think not knowing PHP is a deficiency you need to rectify. Is not knowing Rails, Django, J2EE, node.js, etc. a deficiency you need to rectify? Is there a real demand for you to know and use PHP in your current line of employment? –  Raynos Nov 5 '11 at 15:53
1  
@Raynos Well the popularity of php is larger than rails, django, node.js combined... –  Yannis Rizos Nov 5 '11 at 17:45
    
Why (not a flame) do you want to get better with PHP? Is it for learning to develop in a more dynamic, interpreted environment or more just because so much is out there? –  sbrenton Nov 5 '11 at 18:23
1  
@Raynos - market share. Odds of some knowledge about php being useful to compare solutions, evaluate a problem, help a friend, etc are higher than the examples you listed imo. I have no desire to move away from asp.net, so knowing the "best" alternative environment is less useful imo than knowing the most popular. –  Eric Nov 5 '11 at 20:29
1  
Get into MVC3 that could be a good first step –  Daniel Little Jan 23 '12 at 3:53

2 Answers 2

up vote 7 down vote accepted

The best resource out there to learn PHP is the PHP manual. It's extremely well written and well structured, and it's one of the biggest assets of the PHP community. If you are confident with ASP.net, the manual is enough to get you started.

Before you start reading though, you should setup a PHP stack. You can install Apache, PHP and your favorite database (SQLServer is fine) by yourself (it's extremely easy) or you could setup a ready made stack like XAMPP. XAMPP will install:

all in one go (plus some other stuff). One important library it's missing is phpUnit, that obviously will help you with unit testing.

Then you should install an IDE, your obvious choices are Eclipse Classic with the PHP Development Tools (PDT) or Netbeans for PHP. There are a lot of others, but these two I recommend. I use them both, if you can't choose between them Netbeans is a little easier to get the hang of, but you should really evaluate both and decide for yourself which one is better for you - I haven't worked with Visual Studio in a long time and I really don't know which IDE may feel more familiar to you.

When you get over the basics from the manual, you should start thinking of an MVC framework. Again, I will recommend two:

Zend Framework is the beast and CodeIgniter is the beauty, if you allow me a silly metaphor. Zend Framework has a steep learning curve, is backed by Zend (the company behind PHP), and you can do almost everything with it. CodeIgniter is a lot easier to get the hang of, has nice documentation for beginners and it's fairly popular. But most of it's codebase is outdated crap, as they used to support PHP4 not so long ago.

For a beginner the obvious choice is CodeIgniter, but don't get stuck with it. Use it as a learning tool and move to Zend Framework as soon as possible. Again there are a lot more MVC frameworks in the PHP world, but these two are the ones I recommend.

As for books, a great non beginner book is PHP Objects, Patterns and Practice. Sitepoint's PHP books are always a delight to read. If you fall in love with PHP you should really consider a subscription to PHP Architect.

Lastly, check out this great discussion on purely technical reasons for PHP as a first choice.


Update: A few more online resources, that mostly target non beginners:

and if for some weird reason you want to play around with PHP on IIS instead of Apache, a good starting place is Microsoft's PHP on Windows. PHP on IIS works and is a valid choice especially for a .Net developer, but you should really go with Apache (and MySQL or PostgreSQL instead of SQLServer) to get the full PHP experience and also ensure that your skills are portable to any other popular OS. You don't want to miss out on the joy that is mod_rewrite.


Personal note: There's a lot of hate floating around for PHP, some of it is justified. If you do decide to go for it, you must be extremely critical of the various PHP resources, scripts, libraries you will meet along the way, there's too much crap out there and it's impossible for a beginner to know the difference. PHP's vast popularity can be translated to a very big and helpful community, large marketability of your skills, millions upon millions of blogs, but it can also be translated to a few thousand terabytes of crappy code.

share|improve this answer

Yannis has a lot of good stuff to say there but I read, Build Your Own Database Driven Web Site, 4th Edition, and it was filled with everything I needed to know to get started on the right path to developing professional PHP web applications.

I was also working exclusively on .NET before I started doing some PHP work. PHP is a lot easier to work with but has some peculiar issues when developing large scale applications and this book gets you started on that.

One issue for me was that how PHP is not strictly an Object Oriented language. It has all sorts of functions in procedural form and Object Oriented form and it kinda takes a while to get used to, coming from a language where everything is organized into classes and namespaces.

Another one was how easily you can mix up everything in PHP making things a lot more difficult. In .NET the tools that you use, such as Visual Studio, guide you to actually practice good coding standards by doing some of the work for you. Usually a .aspx page would have it's HTML Markup and C# code separated into two files.

If you are a heavy user of .NET tools, and prefer to work with ASP.NET controls, still another is issue for you would be the lack of controls (GridView etc) in PHP. I know that there are a lot of libraries/frameworks that give you something similar but they are not exactly part of the basic PHP package.

Another issue for me was how in PHP, there is heavy use of Arrays and Hashes serving more like collections in .NET. They are everywhere and it would be a good to get used to the fact that arrays are not just an ordered list of the same type of objects/scalar units. They can server as a collection objects to house all sorts of stuff.

I can go on and on but to mention one of the major things I found very peculiar to PHP (I don't know it could be also common in other languages), is how often the "include" (and related) functions are used so commonly. I can say that the book from Sitepoint can get you up to speed with all of this.

share|improve this answer
    
I've got a link to Sitepoint's php books in my answer, they are all excellent. Could you expand your answer a bit to tell us of the peculiar issues when developing large scale applications you've identified? Since you have a .net background as the op, it would be helpful to know what .net people feel is peculiar about php. –  Yannis Rizos Nov 11 '11 at 3:10
    
OK Yannis, one issues for me was the how PHP is not strictly Object Oriented, it had all sorts of function in procedural form and Object Oriented form and it kinda take a while to get used to coming from a language that so organized into not only into just classes but all those name spaces and everything. –  tsega Nov 11 '11 at 3:22
    
Hmmm, that's a general issue, not just when developing large scale applications. Anyways, I was thinking more of conceptual & approach issues, like PHP takes a completely different approach from .Net on scaling issues, something like that. I have very little experience with .Net so I would be interested to find out what the .Net people find conceptually peculiar when coming to PHP. But stuff like the fact that PHP is multi-paradigm are to be expected, of course. –  Yannis Rizos Nov 11 '11 at 3:26
1  
In terms of approaches, most ASP.NET developers tend to use custom controls (components - which are a combination of HTML controls with Javascript and server side code) to develop their "large scale" (data intensive) applications. This is mostly due to the fact that most ASP.NET developer have actually moved to web development from desktop application development using almost the same tools. Therefore, most seek for ways to translate their already acquired skills of working with custom controls to fit web development. –  tsega Nov 11 '11 at 4:25
    
A very good IDE to got with this Book is Netbeans. The PHP debugging is as good as it gets. –  tsega Nov 11 '11 at 4:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.