成为PHP专业人员:缺少的链接

When reading various PHP related blogs, Quora questions, Google+ communities, newsletters and magazines, I often notice extreme polarization of skill. Questions are either at the "How do I connect to a MySQL database?" level or something in the range of "How do I best scale my mailing system to send over one million emails per hour without introducing a new server?"

在阅读各种与PHP相关的博客,Quora问题,Google +社区,新闻通讯和杂志时,我经常注意到技能的极端分化。 在“如何连接到MySQL数据库?”中有一个问题。 级别或“我如何最好地扩展邮件系统以在不引入新服务器的情况下每小时发送超过一百万封电子邮件?”范围之内?

I personally distinguish between 4 distinct levels of PHP prowess (likely applicable to any language/profession): beginner, intermediate, professional and elite.

我个人区分了PHP技能的4个不同级别(可能适用于任何语言/专业): 初学者,中级,专业和精英

极端 (The extremes)

In PHP, beginners learn about variables, includes, form processing. They learn simple logic constructs. They send an email with the help of a tutorial, maybe even touch on an object oriented programming example without actually understanding it. They work with WordPress and modify a couple CSS classes. With this knowledge, they apply for jobs and, unfortunately, usually fail.

在PHP中,初学者学习变量包括 表单处理 。 他们学习简单的逻辑结构 。 他们在教程的帮助下发送电子邮件 ,甚至可能在没有真正理解它的情况下接触一个面向对象的编程示例。 他们使用WordPress并修改了两个CSS类。 有了这些知识,他们就申请了工作,但是不幸的是,他们通常会失败。

Professionals are those who have given good parts of their lives to many projects. They've deployed commercial applications in most if not all frameworks, they've used different databases with PHP efficiently, they visited and/or talked at conferences. They studied design patterns and can easily engineer an entire project on their own from diagrams to execution. They left procedural code far behind.

专业人士是指那些将大部分时间都投入到许多项目中的人。 他们已经在大多数(如果不是全部)框架中部署了商业应用程序,他们已经在PHP中有效地使用了不同的数据库,并在会议上进行了访问和/或讨论。 他们研究了设计模式,可以轻松地自行设计整个项目,从图表到执行。 他们把程序代码远远抛在后面。

Elite programmers are professionals who put in the fabled 10000+ hours into honing their skill. They supplement their PHP installations with extensions they wrote themselves, they find bugs just by glancing through source files, they are extremely meticulous about their code layout. They reject all but the most complex projects and find alternative and imaginative ways to solve problems people didn't even know they had. They've written some well received books about the language, spoke at dozens of conferences, maybe even made their own branch of PHP or a highly successful framework or two.

精英程序员是专业人员,他们花了10000个小时以上的时间来磨练自己的技能。 他们用自己编写的扩展名对PHP安装进行补充,仅浏览源文件即可发现错误,并且对代码布局非常谨慎。 他们拒绝除了最复杂的项目之外的所有项目,并找到其他解决方案,并且以富有想象力的方式解决人们甚至不知道的问题。 他们写了一些有关该语言的畅销书,在数十次会议上发表了演讲,甚至使自己成为PHP的分支或一个或两个非常成功的框架。

So in all this, who are the intermediate ones?

那么在所有这一切中,谁是中间人?

缺少的链接 (The missing link)

How does one get from beginner to pro and beyond? If one doesn't know anything beyond the basics, how can they improve their skill enough to leave the bad practices behind and start practicing the more advanced approaches? This is a question I get asked a lot by beginners. In order to become a professional, one must first become intermediate.

一个人从初学者到专业人士又如何超越? 如果一个人除了基本知识之外一无所知,他们如何提高自己的技能,以将不良做法抛在后面,而开始实践更高级的方法? 初学者我经常问这个问题。 要成为专业人士,首先必须成为中级。

What follows is a list of what one should go through on the path to PHP fluency.

下面列出了在PHP流畅度上应该经历的清单。

放弃意大利面代码 (Abandon spaghetti code)

Many people think using classes means you're writing object oriented code, while using functions means you're writing procedural code. While this is false, for the sake of this argument, let's assume the widespread vanilla definition: procedural code is code in which you simply don't use classes and objects, and OOP code is code in which you use classes and objects as much as possible.

许多人认为使用类意味着您正在编写面向对象的代码,而使用函数意味着您正在编写过程代码。 尽管这是错误的 ,但出于此论点的缘故,让我们假设一个广泛的原始定义:过程代码是您根本不使用类和对象的代码,而OOP代码是您尽可能多地使用类和对象的代码可能。

My advice is to fully abandon procedural code. Use object oriented coding style as much as possible – write classes, encapsulate logic, think with real world terminology. The performance benefit of procedural code over class based code is negligible when compared to the re-usability that proper OOP code gives you and future developers inheriting your project. A common argument against this is "But, WordPress is procedural!" To be frank, and this might sound harsh, "WordPress developers" are no more PHP developers than people with Instagram are photographers. Please don't take this to mean WP is useless – it's fantastic for blogs, simple websites and one-day projects you don't want to spend too much time on. It's excellent for making a quick buck or for people who aren't too technical, but mastering WP will never make you a professional PHP developer – it's a yarn of spaghetti code that can teach you no proper design principles.

我的建议是完全放弃程序代码。 尽可能使用面向对象的编码样式-编写类,封装逻辑,使用现实世界的术语进行思考。 与正确的OOP代码为您和将来的开发人员继承您的项目所带来的可重用性相比,过程代码相对于基于类的代码在性能上的优势微不足道。 一个普遍的反对意见是“但是,WordPress是程序性的!” 坦率地说,这听起来可能很残酷,“ WordPress开发人员”比起拥有Instagram摄影师更像是PHP开发人员。 请不要以此来表示WP是无用的-对于博客,简单的网站以及您不想花​​费太多时间的一日项目来说,这是很棒的选择。 它是快速赚钱或对技术不太熟练的人的绝佳选择,但是精通WP绝对不会使您成为专业PHP开发人员–这是一条意粉代码,无法教给您适当的设计原理。

Start small. Think of a real world concept, and try to represent it in OOP code. Work through some basic tutorials and slowly go more advanced. Work on OOP code until you understand classes in general before transitioning to proper frameworks and confusing terms like "Model", "View" and "Controller" – all these are foggy, abstract terms without having a solid foundation in OOP first.

从小开始。 考虑一个现实世界的概念 ,并尝试用OOP代码表示它。 完成一些基本教程,然后逐步进行高级学习。 在过渡到适当的框架并混淆诸如“模型”,“视图”和“控制器”之类的术语之前,请先研究OOP代码,直到您大致理解类为止-所有这些都是模糊的抽象术语,而没有首先在OOP中扎实的基础。

剖析现有项目 (Dissect existing projects)

Dive into existing source code wherever you can find it. For example, look up PHP projects on Github, clone them, deploy them locally on your own machine and try to play around with the code. Go file by file, line by line, until you understand what each does.

在任何地方都可以找到现有源代码。 例如, 在Github上查找PHP项目 ,克隆它们,在本地计算机上本地部署它们,然后尝试使用这些代码。 逐行逐行查找文件,直到您了解每个文件的功能。

Look for projects that are well commented and/or documented, well structured, and still alive. Projects last updated in 2008 won't do you much good if you're getting into PHP 5.5 – you'll likely be missing out on the latest and greatest features that could make you stand out in an already overpopulated field.

寻找评论和/或记录良好,结构合理且仍然有效的项目。 如果您要使用PHP 5.5,上次更新于2008年的项目对您不会有太大的帮助–您可能会错过最新和最出色的功能,这些功能可能会让您在人满为患的领域中脱颖而出。

学习设置自己PHP环境 (Learn to set up your own PHP environment)

Being able to set up your own environment is a priceless skill. Not only does it allow you to fine tune your setup, it also familiarizes you with building extensions from source.

能够设置自己的环境是一项无价的技能。 它不仅使您可以微调设置,还使您熟悉了从源代码构建扩展。

Abandon Windows for development – if your main desktop is Windows, install virtualization software and run a Linux virtual machine – the case insensitivity of Windows, its line endings, and all other oddities inconsistent with most server environments out there are just asking for trouble, so it's best to develop on a system that most resembles the environment you'll eventually be launching on.

放弃Windows进行开发-如果您的主桌面是Windows,则安装虚拟化软件并运行Linux虚拟机-Windows的大小写不敏感,其行尾以及与大多数服务器环境不一致的所有其他问题都在问问题,所以最好在与最终启动环境最相似的系统上进行开发。

Virtual machines also help you experiment – if something goes wrong, you can just wipe it and start over or do a rollback. You can literally experiment as much as you want without fear of messing anything up. Mastering tools is important, but having a good workbench is too.

虚拟机还可以帮助您进行实验–如果出现问题,您可以擦除它并重新开始或进行回滚。 您实际上可以根据需要进行任意尝试,而不必担心将任何事情弄乱。 掌握工具很重要,但是拥有一个良好的工作台也是如此。

Experimenting with your own setups will also allow you to get familiar with the different servers out there – whether to use Apache of Nginx, whether to use neither of them and go with Appserver, and so on.

试用您自己的设置,还可以使您熟悉不同的服务器-是否使用Nginx的Apache,是否不使用它们以及与Appserver一起使用,等等。

尽早练习最佳做法 (Exercise best practices early)

When writing your own code, make sure you comment heavily with docblocks, indent beautifully and structure carefully. After you build a class, project or library, use well known documentation tools (PHPDocumentor, ApiGen) to extract the docblocks and improve on them.

在编写自己的代码时,请确保使用docblocks进行大量注释缩进精美并精心构造。 构建类,项目或库之后,请使用众所周知的文档工具( PHPDocumentorApiGen )提取文档并对其进行改进。

A good IDE is worth its disk size in gold – getting used to one multi platform editor can help you be up and running in no time when setting up a fresh environment, so you can dive into code instantly without wasting time on setting up keyboard shortcuts and themes. Make sure you back up IDE configuration files on a cloud service like Google Drive, so you have them ready for import at all times even if you need to make a fresh installation. A good IDE is PHPStorm, or if you can't afford it or have no open source projects with which to ask for a free license, Netbeans is a free alternative. Both are multi-platform.

优质的IDE值得其金黄色的磁盘大小–习惯使用一个多平台编辑器可以帮助您在设置新鲜的环境时立即启动并运行,因此您可以立即投入代码,而无需浪费时间设置键盘快捷键和主题。 确保将IDE配置文件备份在Google云端硬盘等云服务上,这样即使您需要全新安装,也可以随时将其导入。 一个好的IDE是PHPStorm ,或者如果您负担不起或者没有开源项目可以要求免费许可证,那么Netbeans是免费的替代方案。 两者都是多平台的。

Getting used to best practices early helps you remain consistent and lets other people read your code much more fluently. Find your style and stick to it – you'll help both yourself and others. Try to follow the PSR standards (PSR-0, PSR-1, PSR-2, PSR-3) as closely as possible – they’re called standards for a reason. Most of us use and love them, and they make everyone’s code equally reusable and readable.

尽早习惯最佳实践可以帮助您保持一致,并使其他人更流畅地阅读您的代码。 找到自己的风格并坚持下去–您将为自己和他人提供帮助。 尝试尽可能严格地遵循PSR标准( PSR-0PSR-1,PSR-2PSR-3 )–它们之所以被称为标准,是有原因的。 我们大多数人都使用并喜欢它们,它们使每个人的代码同样可重用和可读。

A good beginner friendly resource that gives up-to-date hints is PHP the right way – use it to get familiar with the latest best practices, basics of OOP, security, deployment, coding standards I mentioned above, and much more.

一个可以提供最新提示的良好的初学者友好资源是PHP的正确方法 -用它来熟悉最新的最佳实践,OOP的基础知识,安全性,部署,我上面提到的编码标准等等。

尝试不同的框架,选择一种 (Try out different frameworks, choose one)

For a long time, PHP was the language with most frameworks out there (JavaScript took over recently). Whether this speaks of the inconsistency of our community or the popularity of our language, I cannot say, but the fact remains that choosing a framework is a daunting task, especially when first starting out.

长期以来,PHP是使用大多数框架的语言(最近JavaScript接手了)。 我不能说这是说我们社区的矛盾还是我们语言的流行,但是事实仍然是选择框架是一项艰巨的任务,尤其是在刚开始时。

Having tried most of them, I can wholeheartedly recommend Phalcon as the go-to framework due to its robustness and quality, and the fact that it's built in C and installed as a PHP extension (thus being faster than any current framework in existence). However, trying out different frameworks is an absolute necessity.

在尝试了大多数方法之后,我可以全心推荐 Phalcon作为框架,因为它的健壮性和质量以及它是用C内置并安装为PHP扩展的事实(因此比现有的任何现有框架都要快)。 但是,尝试不同的框架是绝对必要的。

When you try them out, you learn about a new approach to a common problem every time. Each framework has its own quirks you'll like and downsides you'll hate but most importantly, you'll learn about the mindset of others (particularly the developers of the framework). You'll see new usages and approaches, and a very good exercise is re-building one of your sample projects in as many frameworks as you can find. This will help you efficiently gauge the efficacy of a particular framework: the speed of developing in it and its performance.

当您尝试它们时,您会每次都了解一种解决常见问题的新方法。 每个框架都有自己喜欢的怪癖和讨厌的缺点,但最重要的是,您将了解其他人(特别是框架的开发人员)的心态。 您将看到新的用法和方法,一个很好的练习是在尽可能多的框架中重建一个示例项目。 这将帮助您有效地评估特定框架的有效性:框架开发的速度及其性能。

(Read)

Don't underestimate the hints and tips of others. Read as much as you can – if you keep at it, it doesn't take as much time as you might think. Find good blogs to follow, read the tutorials on this website, traverse questions and answers on StackOverflow, visit the SitePoint Forums, subscribe to newsletters, follow good sources on Google+. Avoid basic PHP tutorial books – they're outdated as soon as they're published – instead, focus on individual snippets and tutorials of useful up-to-date code you can find all over the web. Even if the topic is something you've already covered, try giving it a read – you'll often find that something new can be learned by reading someone else's perspective on the very same thing.

不要小看别人的提示和技巧。 尽可能多地阅读-如果继续阅读,它不会花您想像的那么多时间。 查找可关注的优秀博客,阅读本网站上的教程,遍历StackOverflow上的问题和答案 ,访问SitePoint论坛 ,订阅新闻通讯, 并在Google+上关注优秀资源 。 避免使用基本PHP教程书-它们一经发布便已过时-而是着重于各个片段和有用的最新代码的教程,您可以在网上找到这些有用的最新代码。 即使您已经讨论过该主题,也请尝试阅读一下-您经常会发现,通过阅读别人对同一件事的观点,可以学到一些新东西。

如果没有工作,请发明一些 (If there's no work, invent some)

There is always something to do. Never catch yourself saying "I don't have a project" or even worse, "I'm bored". If you don't have an active project to work on – make one up. Do you use a tool daily that frustrates you with its lack of functionality? Build a better alternative! Have no ideas for new products? Replicate existing ones – try rebuilding a basic Facebook, recreate something you already know exists just for practice.

总有事情要做。 永远不要让自己说“我没有项目”,甚至更糟的是,“我很无聊”。 如果您没有正在进行的项目,请完成一个。 您是否每天都使用一种因功能不足而感到沮丧的工具? 建立更好的选择! 对新产品没有想法? 复制现有的-尝试重建基本的Facebook ,重新创建您已经知道的内容,仅用于练习。

What's most important is to never stop – there's no amassing 10000 hours if you don't put in the hours! Keep working, keep yourself interested and engaged. Make a simple address book app. Then rebuild it in another framework. Then rebuild it with another database (replace MariaDB with Mongo, for example). Keep busy!

最重要的是永不停止-如果您不花时间,则不会累积10000小时! 继续努力,保持自己的兴趣和参与度。 制作一个简单的通讯录应用程序。 然后在另一个框架中重建它。 然后用另一个数据库重建它(例如,用Mongo替换MariaDB)。 保持忙碌!

寻找伙伴/导师 (Find a buddy/mentor)

It's easier to learn when you have someone to do it with. Find a buddy who shares your passion. Maybe you're one of the lucky few with a partner who shares your geeky interests. Maybe you're in school or university and have peers who would like to get started as well and need companionship in these adventures. You can even find a mentor and receive expert guidance.

与他人一起学习时更容易学习。 寻找一个与您志同道合的伙伴。 也许是与您分享怪异兴趣的合作伙伴中少数幸运的人之一。 也许您正在上学或上大学,并且有一些同行也想入门,并且在这些冒险中需要陪伴。 您甚至可以找到一名导师并获得专家指导。

Never underestimate the power of a companion – there's a reason The Doctor always has one!

永远不要低估同伴的力量-这是医生总是有一个的原因!

结论 (Conclusion)

When you focus on all these entries with as much will as you can muster, when you realize it's what you want and keep at it – you're on the road to becoming a PHP pro. Maintain discipline, never give up (even if others around you do) and keep practicing.

当您全力以赴地专注于所有这些条目时,当您意识到自己想要并坚持下去时,就意味着您将成为PHP专业人士。 保持纪律,永远不要放弃(即使周围的人这样做)也要继续练习。

If you've got any useful resources you'd like to share with us on how you bridged (or are currently bridging) the Intermediate gap, let us know in the comments below!

如果您有任何有用的资源想与我们分享如何弥合(或正在弥合)中间差距,请在下面的评论中告诉我们!

翻译自: https://www.sitepoint.com/becoming-php-professional-missing-link/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值