返回正常中文阅读
想对这篇译文“指手画脚”吗?
大错
小错
不顺
建议 5 essential development facts every PHP developer should know
There’s always a bridge between textbook knowledge of programming - syntax, procedure etc. - and the real world knowledge that you get from actually developing real applications. Here are five things every PHP developer should be familiar with before they begin developing web applications in PHP.
1. Frameworks
Frameworks are arguably one of the most important areas of PHP development. With no single accepted way of developing web applications in PHP, a number of open source frameworks are available, helping you code quicker, more consistently and more effectively. Some of the best include CakePHP, Symfony and CodeIgniter. A lot of the frameworks also follow the MVC design pattern, which you should definitely be familiar with should you ever have to work on code that follows it. After a while, you may even feel inclined to create your own framework to meet your needs.
2. Templating engines
If you’re not using a framework that enforces a specific design pattern, chances are you want to be using a templating engine. Whether you create your own or using one of the existing options (like Smarty), a templating engine allows you to entirely seperate your code logic from your HTML interface code (and associated CSS/JS/etc.). This considerably simplifies your code, allows quick and easy modifications to the actual front-end of your application, and makes it easier for non-developers to modify your application’s visuals.
3. Code availability
As I mentioned in a previous post, PHP has some of the best code availability of any language. From various snippet archives to entire class databases, PHP developers are really spoilt for choice when it comes to reusing existing code. In fact, you can almost get away with building an entire application without writing a single line of code.
4. Don’t reinvent the wheel
This might seem fairly obvious, and a little part of the previous point, but very few PHP developers realise how much power is already available as part of PHP itself. Forget pulling in new libraries, or writing long complex code routines - first take a look at the PHP manual. For example, have you ever heard of number_format(), parse_url(), wordwrap() or bbcode_parse()? Take a look at the entire function reference, pick a category and have a browse - you’re bound to find something new.
5. IRC is a wonderful thing
For when you’re stuck on a complex problem that you just can’t make sense of, hop on IRC. The ##php unofficial support channel on Freenode is always full of experienced PHP developers happy. You’ll need an IRC client - ChatZilla is great if you’ve got Firefox - and a little patience; when you need help, pastebin your code and head to irc://irc.freenode.net/php. Post your question and wait patiently; some kind soul (or multiple kind souls!) will answer. When you’ve finished, consider lurking in the channel to help others with their problems. No man is a mountain, especially with PHP’s enormous library of functions; on IRC, the pool of collective knowledge can solve just about any problem.
每一个PHP开发者应该知道的五必不可少的发展要素
语法结构教科书上的知识和实际的程序设计是有区别的,真正的知识要在实际的开发中获得。每个php的开发人员在开始开发web应用程序之前,都应该熟悉下面的五件事:
1. 框架
框架可以说是php开发中的一个最重要的问题。 用php开发web应用程序时有很多方法,有很多开源的框架可以使用,可以帮助快速的开发,保持更高的一致性和有效性。 其中比较好的框架包括cakephp ,Symfony和CodeIgniter 。很多框架还按照MVC设计模式 ,如果你在这个模式下工作过,那你一定会很熟悉。过一段时间,你甚至可以根据自己的需要来创建框架。
2. 模板引擎
如果您使用的不是一个框架来执行一个具体的设计模式,那么您想要使用的是模板引擎。不论你是自己创建或是使用现有的模板(如 Smarty),模板引擎都会使你的逻辑代码从HTML页面中独立出来(以及相关的CSS / js /等)。 这大大的简化了你的代码,使整个程序的修改变得快速简单,也使非开发者更容易修改你的程序。
3. 代码重用
正如我先前提过的,php是所用语言中代码重用性最好的。从多中小的文档到整个数据库类,php开发者需要的时候可以随意的选择重用现有的代码。其实,你几乎可以不用编写一行代码就能建立起整个应用程序。
4. 不重新开发现有的东西
很明显的一件事,只有少数的php开发者知道php本身有很多可用之处。忘记新的图书馆,或复杂的代码例程-先看看PHP手册。 例如,你们有没有听过number_format(), parse_url(), wordwrap()或bbcode_parse()?看一下整个函数参考 ,选择一个类别,浏览一下,您一定会有所发现。
5. IRC 是令人愉快的事
当你有个复杂的问题不能解决的时候,可以到IRC上。php非官方的支持频道,很多经验丰富的开发者陶醉其中。你需要一个IRC客户端,如果你用的Firefox,ChatZilla是一个很好的插件,当你需要帮助时,以irc://irc.freenode.net/php做为头部粘贴你的代码。张贴您的问题,并耐心等待;某种热心人(或多个)会给你答案。当你得到答案后,考虑一下其他需要帮助人的问题。对于php庞大的函数库来说,没有人是泰斗;在IRC上,汇集所有人的知识就可以解决任何问题。
