About Php development [closed]
I have developed two projects: one in osdate and other is my own code. I want to improve my code standard. Can anyone suggest a standard and 开发者_如何学JAVAhow to organize a project before starting? I don't have any senior programmers in my office and so I have to learn by myself.
Have a long hard look at php codesniffer and phpmd (note there is some overlap between these but they do cover different aspects)- pick a coding standard and use these programs to check your code.
Do use a version control system. Do use a code documenter (like PHPXRef, PHPDoc) and comment your code accordingly. Plan Unit tests and set up continious integration testing.
Plan how you are going to manage / test your code before it is released to Live, (i.e. keep live and test code separated).
In fact, plan everything - but be prepared to change your plans as the need arises.
Take the time to record the bugs you find before you fix them - then periodically review what kind of bugs keep occurring in your code and what you can do to avoid them in future. See also PSP
There are lots of Open Source projects out there looking for developers - this is a great opportunity to get your code reviewed by other people (hopefully whom know what they are talking about) and see how a large project works.
HTH
C.
In relation to organising your php project, I would probably aim to
- Sit down with some paper and a pen and design your whole project on paper. It's always going to be easier to see potential problems before they arise if you know ahead of schedule what might go wrong.
- Regarding 1, this will involve what data types are going to be used, and where and how in your front end UI you will be asking for data and what it should look like - that'll help with writing your php. All fairly standard approach really.
- Regarding coding standard, try here for one.
- Create a decent test plan. I prefer to do this towards the end of development as things are bound to change during your development cycle. Every area of your php code must be tested so you're satisfied it all works as expected - including boundary exceptions. Again, fairly standard stuff really.
A great way to improve yourself as a developer is to read other peoples code.
There are plenty of open source projects out there that you can poke through to see how other people approach things.
Whilst other peoples code may not always represent the 'right' way, it's important to see different approaches and have a mark against which to judge your own code.
A good example of coding standards is:
Zend Framework Coding Standard for PHP
- Overview
- PHP File Formatting
- Naming Conventions
- Coding Style
One of the best ways to improve PHP code is to use an MVC Framework, that will force you to split your data models from your HTML pages and your Controllers.
A good MVC frameworks for PHP Beginners is Codeigniter. It will only take you a few hours to get used to the methods they use, and they have some good video tutorials on it that will get you going in no time.
精彩评论