I have been writing code for almost 20 years. It hasn't always been PHP, the first 6 or 7 years I was very involved with the Java world.
While I partially agree with people thinking you can write bad code with PHP (more than other programming languages), I personally think that you can write bad code in any language because bad practices are common for all of them. For instance, you can call functions or initialize variables inside a loop, you can hit database many times, or you can repeat yourself no matter the language you use.
That said, I want to list the most common questions that good developers should never ask themselves.
1. Are you serious? Is it possible to add code to tables / entities?
If you want to be a bad CakePHP developer, this is your golden rule. Almost every code we receive for review follow this one. Controllers with thousands of lines and models with just baked code. That’s wrong because all the logic related to your tables should never be in your controllers (or helpers / views).
2. I love using SQL queries in my code, is it really so bad?
The short answer is YES. It’s bad, really bad. It is the greatest source of issues and unpredictable behaviors. It is hard to test but of course if you are asking this question you will probably ask the next one.
3. Tests? Baked tests are enough, aren’t they?
Ehm.. no. You won’t be a bad developer if you don’t have 100% coverage. Even more, I don’t like to talk about what coverage is good because it exclusively depends on the project itself. I would say that you should feel good if your core features are fully covered.
4. Why should I put the code in one place only if you can copy and paste it everywhere?
Even most modern IDEs identify this as a bad practice now, but this is something we see in almost every code we get for review. People prefer to copy and paste the same function in multiple classes instead of creating a Component or Behavior or even a library and use it everywhere.
5. Plugins? What is a plugin?
CakePHP has a very large set of available plugins, or you can always start your own plugin and publish it so other people can use it. Plugins are one of the most important features in CakePHP since you can encapsulate a feature or a set of features to use them in multiple projects. Just be careful and don’t overplugin.
6. How the hell would somebody hash a password?
Well, even when you think it's a joke, no, it's not. Some people think hashing a password is not required. CakePHP provides several options for password hashing to secure your application.
7. Do you document your code? I don’t think it is useful.
Having the availability of documentation aids in understanding the intended use, as well as the expected functionality and result of the code's execution. It is pretty easy if you just document your code while you are doing it instead of waiting to have 20 classes to document.
8. Should I declare variables to execute find methods / DB / Service requests or should I put them inside a for/while loop to "save" memory?
Please no, doing external service requests (DB / File / Web Service) from inside a loop affects application performance very badly. You should always try to put the result in a variable and then use it inside the loop.
9. Who needs coding standards?
Coding standards help make code more readable and maintainable. For CakePHP applications, the Cake Conventions and Coding Standards should be applied.
10. Is it better to make all calculations inside for/while loops level in code instead of calculating at the DB/query level?
Data iteration at the DB level offers way better performance than iteration done at the application level.
To summarize, for sure there are lots of things to look at, but from my perspective these are the 10 basic questions that can define you as a good (or bad) developer.
I hope you've never had these questions before but if you do, don’t worry about it, don’t tell anybody, just follow these recommendations to improve yourself!