📜 ⬆️ ⬇️

Scary tales about PHP5, told at night ...

1) No matter how much nonsense you do with PHP, the bottleneck is always - DB. PHP is like Pinocchio - stupid ... firewood. Lighttpd and Nginx allow you to spread it across multiple physical servers at times without noise and dust. The salary of an adequate PHP specialist in Moscow is 30-45 thousand rubles per month, the cost of renting a normal server is from 3 thousand rubles per month. And you did not know;)?

2) Whatever nonsense you do - 30-60% of the performance (and possibly more) of the PHP code will be decided by the correctly selected and configured accelerator.

3) No silver bullet. It doesn't matter what concept you use - strict OOP (in the Zend Framework style), functions in the PHP4 style (or limited OOP) or noodles in the style “PHP for dummies” - none of these paradigms will give tangible performance gains, unless of course your programmers are no taller than their heads.

')
4) The fastest code is a code that does not exist. And certainly - when there are no queries to the database (see item 1). So caching is by far the way high performance begins. Feel free to hammer in on any optimization, as long as there is an opportunity to cache something. You can cache everything. The only question is how to send notifications about the need to update certain parts of the cache. (Maybe someone remembers the free-lance.ru website bugs, when in different places the same numbers were different, which was why there were many misunderstandings. This is a shame.) And as a rule, the higher the level of abstraction, the lower the performance code, and the greater the possibility of caching at the same cost man-hours. And as a result, on a higher abstraction, you can squeeze more final performance due to caching. But this is someone who knows how :) (see p. 3).

5) If you think echo is faster than print, you are a loser. In modern MVC projects, as a rule, similar features are called up to a maximum of three times: in the front controller, in the AJAX controller and in the RSS controller — that is, a maximum of three operators output to the standard stream for your entire large project.

6) If you pray on the Zend Framework's Front-Controller, this is your right. But his concept "/ key / value /" is considered revolutionary by people who have not seen anything other than? Key = value & foo = bar, but someone has used the concept / virtdir1 / virtdir2 / virtfile / using ERROR 404 dirty hacks, zadolo to ubiquitous appearance on virtualhosting (and very long before the appearance of VDS) mod_rewrite (and PHP5;). Of course, the ZF front controller is very flexible, but isn't it easier to write your own? All of the above is true only for large projects, if you write a lot of small ones - this is not for you (zayuzayte standard Front Controller ZF and focus on the ease of support).

7)
echo "preved $ foo $ bar";
echo 'preved'. $ foo. ''. $ bar;
echo 'preved', $ foo, '', $ bar;
sprintf ('preved% 1 $ s% 2 $ s', $ foo, $ bar);
You, as a seasoned professional hayola, can say with closed eyes, which design is faster? Relax the anus, my friend - you are a loser.
You can accurately and convincingly say which concept to choose as a standard within a large project - respect.

8) Forget and permanently send virtual servers to the deep anus, as your worst dream. Go and buy yourself a virtual dedicated server with root rights for> = 150 rubles per month. And put your favorite Debian / Gentoo / FreeBSD there, and control it like Root Almighty! From now on you are free! :)

9) If your PHP machine runs under Windows, you smell flowers in a gas mask. If you want to become a professional server programmer under * nix - safely demolish Windows and install * nix (Linux, FreeBSD, OpenSolaris, etc ...) If there is no such goal, you can run * nix server in a virtual machine (Virtual Box, VMvare, etc ...), but please do not torture PHP - do not drive it under Windows ...

10) If PHP works on your working machine without an accelerator, you smell flowers in a gas mask, wear a respirator, and over these glamorous clothes you are still wearing ... TANK! Install the accelerator already, damn it! (upd: I mean development machine)

11) If you think you have mastered PHP5 perfectly, you are a loser. There is always something to learn. If you know exactly who you have something to learn from, you can stop reading.

12) PHP5 (PHP4 forget how terrible a dream!) Is a very cunning thing. There are too many people there. Most programmers are at the level “below the baseboard”. And some of them manage to write smart books (by the way, I still have not seen a single normal book on PHP5), and teach people the "subtleties of PHP programming" in many other ways. Learn to separate the wheat from the chaff - that is, dummies from professionals, this skill will be one of the most important for you. Learn from the professionals. Maybe you can’t imagine how much time can be wasted trying to learn something from dummies (and by the way, also don’t believe me;)

13) And do not believe anyone who claims that PHP5 is a “bad” technology until you get at least 90% of it and you won’t know exactly what you are missing in it;)

upd: Naturally, all of the above applies to those projects where there is at least some complexity and burden.

Source: https://habr.com/ru/post/22881/


All Articles