DISQUS

Md Emran Hasan (phpfour): Becoming a Kick-ass PHP ninja

  • Masud · 1 year ago
    all the points are very important. most of us are well in php but maximum time we fail to update ourself becz of proper guidance.

    thanks for this informative post.
  • Chekke · 1 year ago
    With due respect to PHP and this blog but after reading all this suggestions why no better use Java and be done, It have all what you suggest but much better than PHP, PHP has been a kitchen sink since the beginning so it drives to people to make a mess on their code, And also Dynamic languages have similar problems as statically languages when the code grow.

    1.Version control: All programming languages should use it even I use it for my excel docs.
    2.OOP: Java it drives you to do proper OOP.
    3.Coding Standards and Patterns: Java have it too in a higher degree.
    4.Document your code: Java have thousands of good tools for it.
    5,6,7. Java have gazillions of neat frameworks to choose, use JUnit for testing, Java is a proper OOP you can reuse your objects and components check Spring, Guice, OpenEJB those can help you to do it much better.

    8,9,10.Same in Java as PHP.

    11. Good IDE: Java have awesome IDEs with awesome refactoring tools and much more, Eclipse, Netbeans, IntelliJ, Borland JBuilder, MyEclipse.

    12.Java same as PHP.
  • Md Emran Hasan (phpfour) · 1 year ago
    @Chekke: In my opinion, Java and PHP both are excellent languages and they have their own place where they excel. Although Java can be used in almost all scenarios, for web based solutions PHP can be more handy than Java. It allows developing and deploying quality web application in record time. And with the latest additions to the PHP language, these applications can be robust and secure.

    I suggest you keep an eye on the latest trend in PHP, you'll see that it's quite a mature language right now. I've seen people using both PHP and Java, which they use for specific need.

    Thanks for your comment though :)
  • design · 1 year ago
    A guide for newbie PHP developers to become a kick-ass PHP ninja by upgrading themselves through a number of technical and personal improvements.
  • Frank · 1 year ago
    Chekke, sure I'd use jsp's and jsf's over php any day
  • Vincent · 1 year ago
    The reasons for coding OOP could be more elaborated. OOP by itself doesn't force you to write more maintainable code - when I started writing OOP my classes where just containers for static methods which I used just like I used functions. It wasn't until I started using the Zend Framework that I really grokked the benefits of OOP and how to use it effectively.
  • Chekke · 1 year ago
    @Emran Hasan, Thank you for your message at DZone, I will take a look more close to PHP.

    @Frank, Im not interested in the template that is the easy part, Im interested in the model or controller code or the code behind.

    The templates you could use Freemarker for a MVC framework or Facelets for JSF, it is similar as PHP templates. Take a look at Freemarker or Facelets are just xhtml templates. JSF it is a spec for web component based frameworks, It is not a template language, JSP it is the template but is not the best practice to use with JSF and I'm agree JSP sucks, thats why there are other alternatives and much better.

    But also I'm agree with Emran Hasan that PHP can be helpful in some situations and Java in others, I'm just suggesting that if you care a lot about OOP or best practice and patterns Java it is better option IMHO.
  • Music · 1 year ago
    Great info
  • Gerarg · 1 year ago
    Bwahahaha, no mention of symfony at all, you make me laugh dude with your ninja stuff :D
  • Md Emran Hasan (phpfour) · 1 year ago
    @Gerarg: I've just put a few of them. Added Symfony and Kohana in the list now. Thanks for pointing out.
  • Jérôme · 1 year ago
    I would recommend to use eZ Components coding standard instead of eZ Publish ones. eZ Publish ones are almost deprecated.

    http://www.ezcomponents.org/contributing/coding...
  • Md Emran Hasan (phpfour) · 1 year ago
    @Jérôme: Just added that to the list, thanks.
  • Wesley Mason · 1 year ago
    Good post.
    Bit disappointed to not see VIM in the list of good IDEs.

    OpenSSH + GNU Screen + VIM + VIM aliases & scripts === the win
  • Md Emran Hasan (phpfour) · 1 year ago
    I also love vim, but as a great text editing tool. It's not an Integrated Development Environment (IDE) in the true sense. An app needs to have loads of bells and whistles to be considered to be an IDE :)

    Thanks for your comments!
  • kl · 1 year ago
    Don't forget - use templates!
  • Richard Farrar · 1 year ago
    Very helpful post. I will definitely be adopting some of your points, although maybe not all in one go.

    Think that phpDocumentor will be first on the list, as I already pretty much follow the coding standards.
  • RKG · 1 year ago
    For code testing purposes, Selenium IDE extension for Firefox (http://selenium-ide.openqa.org/) is an impressive tool.
  • bijon · 1 year ago
    Very helpful guidelines for the developers. These guidelines are very standard, unique and latest. I am sure so many developers get this direction from here. Thanks a lot for sharing these.
  • Matt · 1 year ago
    Good article. It overlaps quite a bit with my own tips for new programmers and coding standards.
  • murshed ahmmad khan · 1 year ago
    Very good & helpful article for the potential newbies who want to do well.
    Now we can just forward the link of this post to the newbies instead of giving them a long lecture :D. Good job.
  • Md Emran Hasan (phpfour) · 1 year ago
    Thanks murshed bhai :)
  • João Mello · 1 year ago
    after the post, i see the trial of NuSphere PhpED
    and liked...

    thnaks, good tips ;]

    Mello.
  • joshsharp · 1 year ago
    Hey, thanks for the mention! Great post.
  • graffiti · 1 year ago
    becoming a kiss-ass php ninja without any control on security ???
    im just a php beginner but you should talk about this point...
  • Md Emran Hasan (phpfour) · 1 year ago
    Yes, that's true. Security should always get great attention when developing quality applications.
  • pete · 1 year ago
    Hello, good post. There never seems to be enough time for me to do OOP :)
    I am a micro-manager with code and I understand by building, that's why I like to re-invent the wheel, make sure when I do I take a good look at the wheel from security, flexibility.
    I love the thought process of event driven :) It just feels to intuitive and the web really is 100% event driven, it's a disconnected system and you can only rely on one event at a time.
    I just don't have that magical OOP feeling for the web.
    When I develop outside the web I do C and C++, and it's a different world the communication is different. And While I develop AJAX JSON stuff in web, I always start with the assumption that the user and session is completely disconnected and never treat it like a real app.
    I spent the time to write a very extensive and well rounded class for mysql. Then in everyday use, it just didn't feel right, I can't help but thinking hmm I miss my normal functions :) I miss my quick n dirty mysql_add_my_row($table,$fields,$vars). What am I missing out with on OOP? When I program OOP half of developers whine saying what is this, then the other half whine hey we use cake, you use zend.
    I follow the rest of the practices to the point, svn, inline documentation, code format, etc. I am just not an OOP guy, can someone help sell me on the religion of OOP?
    Thanks for the help! :)
  • Md Emran Hasan (phpfour) · 1 year ago
    Yes, sometimes re-inventing wheel gives you the chance of learning the rope closely. Regarding your mysql class, doesn't it help your life a bit easier by doing stuffs for you? I'd imagine my class would have some functions like thins:

    - read(1);
    - findAll ( "status = 'published'" );
    - update ($post, $id);

    to speed up my development time. Back in my head i know the generated queries are safe, structured and does their work pretty good. Just my thoughts :)
  • Rob Lang · 1 year ago
    Using a framework doesn't make you a ninja. PHP is not really designed for the use of big frameworks and using one can actually slow your code down. See Rasmus himself telling us why:
    http://szeged2008.drupalcon.org/program/session...
    This is different from writing using software patterns. Writing in software patterns can help.

    Also, being agile as you describe it is different from Agile Development, which is a very specific form of development methodology. Agile Development suits some projects and not others whereas your definition of having a dynamic personality is useful always.

    Also, OOP is a huge overhead for many of the simple functions you need to perform with scripting. Chances are, if you need to make something huge, scalable and quick then you're going to write the guts in your favourite compiled language such as Java/.NET/C/C++ etc. PHP is not designed for that and so falls down on fast backend processes.
  • Md Emran Hasan (phpfour) · 1 year ago
    Yes, I read Rasmus's post earlier and somewhat agree with him. But I've also read one of his interviews in Sitepoint where he mentioned CodeIgniter to be a framework that actually looks like a framework to him and has some good use.

    In my personal opinion, some frameworks just try too hard to bloat everything and loses the main focus. For me, the objective of a good framework has to be providing structure to projects and provide a number of useful functionality like db abstraction, security, caching, profiling, url mapping, helpers, etc etc.

    Regarding PHP's speed compared to other compiled language, it's a plain truth. A scripting language can not be as fast as the compiled ones. However, it can more or less handle the pressure of web - at least upto a few millions - if the app is developed properly and optimized for large traffic.

    Thanks for your comment :)
  • John · 1 year ago
    "Write code in OOP way" - this doesn't really make sense.

    PHP is a scripting language - don't forget that. Using objects and classes is important, but not vital to proper coding in PHP. Writing all your code within classes like many frameworks out there do creates a lot of overhead that isn't necessary when developing a website, and causes developers a lot of headaches just trying to get a simple website setup with a few dynamic sections.

    OOP is a practice, and in PHP its just an option. Unlike other languages such as Java which are completely object based languages. Utilizing PHP's variable and object scope is much more important in my opinion.

    Things to use objects for: modular information (such as a user entry, or a database wrapper)
    Things NOT to use objects for: normal page procedure (Zend framework does this, and although this is a robust framework it is silly to waste time programming this way when PHP programming is meant to be a faster alternative than other languages - you might as well just use Java to program if you want to do it that way, it will be faster)
  • dazzo · 1 year ago
    if you are not doing this already, then you have lots to learn still. Get to it.
  • Tim · 1 year ago
    I personally do not enjoy Dreamweaver. Snippits stop a developer from going through his or her code, and can pose a threat. Code templates should be avoided. Again, an IDE should not be holding your hand through the process. Rather, they should simply be a utility with little interference. And auto completion seems nice at first, but when you use Prototype or Mootools they do not indent properly. And when you are using strings they attempt to end a tag when you don't want it to. So, again, this feature gets in the way of freedom to code, and hinders the thought and logical process.

    I tend to prefer Scite. Though, with this editor, you can only have 10 documents open which is a pain. And it is missing two very good features of Dreamweaver: Entire site search / replace, and suggestions (which are very handy, specifically with CSS).
  • Wade · 1 year ago
    My biggest issue is all the additional stuff in a framework. For example, Form helpers. They just tweak me off something fierce. I do not believe that they are necessary, and are in fact, an unneccessary overhead. I have been proramming web apps for many years, and I don't understand why people say that using a form help is so much better than just writing the form out yourself? I know all the lines of html code necessary to create a form. Why should I learn a whole set of functions that do what I already know how to do?

    Someone said to me that it keeps the form separate from the PHP code. If you use an MVC framework, you can still put the html code for the form in the view.

    I have used my own type of framework, and my applications have been very quick and snappy. They definitely don't use separate functions and commands listed in arrays to create an input box!?!?!? Why, it's not necessary! I will admit that I may use a function that starts the form an ends the form, but not to populate the contents of a form.
  • Md Emran Hasan (phpfour) · 1 year ago
    I completely agree with you about form helpers, i've always felt
    comfortable writing the html myself.
  • Amit Pansare · 1 year ago
    This is an excellent post.

    Points well covered, and the "further reading material" in each point makes this post very valuable.
    Thanks for sharing this.
  • pixeline · 1 year ago
    you miss the greates of all PHP IDE: waterproof's PHPEDIT http://www.phpedit.com

    not free, but really good: i've used it since 5 years, and its still the best _ lots of plugins to complement it.
  • Maga · 1 year ago
    Great post.

    I think that good freeware IDE for PHP programmers is also Eclipse for LAMP.
  • mr_gadget · 1 year ago
    Thank you for sharing!

    Looks like top point is to Write code in OOP.
  • CastleMonkey · 1 year ago
    While only for OSX, I've found that Coda is an excellent IDE and the one I've settled on after trying most everything else for Windows, Linux and OSX. Coda has all the features I need and none of the extra bloat I don't. If you're a Mac user I strongly encourage giving it a try. http://www.panic.com/coda/
  • Rahat · 1 year ago
    "Write code in OOP way" - What did you mean by this bro?

    OOP is not a way of coding. It's intended to match real world modeling in programming. When you think of OOP then you have to take every entity as object. I think you still really have some shortage of some software engineering knowledge. Though this article could be helpful but finally realized that you are not a true IT Professional. May be diverted form other field to this field. Still lots to learn buddy.
  • Md Emran Hasan (phpfour) · 11 months ago
    Thanks for your reply. I would not argue about the sentence, but tell me one thing: didn't you understand what I wanted to mean? If yes, then I think my target is achieved. And remember, this article is meant for all the newbie PHP developers out there - not only for those who have a software engineering background.

    And don't know what the word "diverted" means here, but I've been programming since college. And if you think I'm not a "True IT Professional" that's fine with me as I don't mind about people saying things that they don't know about - its their discredit, not mine :)

    Oh btw, what is your blog address where I can find good posts on software engineering?
  • pointer · 1 year ago
    Thanks. It is very useful article. My favourite titles are:
    Write code in OOP way,
    Use a good IDE,
    Test your code the right way,
    Re-use code/libraries
  • Roman · 12 months ago
    Nice post. It's a continuous process to follow the system.I think this system is always true, not only for php but also for any other language/project work. Just carefully we follow the process when we do our jobs, we must improve ourselves. But one most important part of learning new technologies/languages/problem solving approach/anything is the last part, "B COMMUNICATIVE". It 'll always improve team work as well as our running project.
  • PHP Designer · 11 months ago
    Excellent article. I tried a framework and found it hard to use because i had to program the way they did. It was expendable however I found it limiting. The other concern I have is it might cause my code to become open source. While I like giving to the community I do not want an application I work on for 300 hours to be vulnerable to becoming open source.

    Learning how to re-use code is probably one of the biggest thing a programmer can do for himself/herself.

    Angain great article!
  • Asad Abbas · 10 months ago
    nice post :)
  • sefat · 8 months ago
    i completely agree with you...!!!! thanx for the amazing post..!
  • Jeremy · 3 months ago
    Summary: Follow the industry best practices.

    Meh