The title was a bit misleading, but it would not be possible to write completely without a title. In this article, we will deepen on PHP, meet the Framework and common PHP tools.
I hope you have liked the mentioned methods for download free shutterstock images. It is good to notice that If you want quality, reliability, variety and good prices, Shutterstock is worth exploring. in in my previous post You had a chance to review the resources I mentioned and I hope you chose one. Although PHP is an easy language to start with, it takes time to deepen. For example, what is the framework? How can we improve ourselves in PHP?
learn english
English is the standard language in the software world for writing software related documents. The default documentation language for PHP is English. So, how will you learn English?
You must reach at least A2 English level to deal with documents. Unfortunately, no matter how many words you know, you're stuck somewhere without grammar. Raymond Murphy's Essential Grammar In Use book will be enough to take you to the A2 level. For B2 level, I recommend the same author's English Grammar in Use book. Although these books are expensive, they are available resources in our country. You need to improve your vocabulary by reading story books suitable for these levels. Since these two resources are prepared in the form of books that you can study on your own, you do not have to spend a lot of money on courses of uncertain quality. On the other hand, books do not teach you to speak English.
Become familiar with PHP documentation
The power of PHP comes from the functions it offers. PHP comes with about 1000 functions in itself. It is impossible to know so many functions and how they are all used. All information about functions php.net you can access the website. For example, on the site array If you search for (array), you can both learn how to create an array with examples and access functions related to the array. Same way W3School You can also find very useful resources on the website. Feel free to add them to favourites. Likewise on Google PHP function name If you search, you can reach various resources written about the relevant function.
Not using PHP and HTML codes together
At first, PHP was used with HTML codes. For example, in early versions of the free software project phpBB ( https://github.com/libreajans/phpbb1/blob/main/index.php) Between the years 2000-2001, PHP codes were generally written as above. You will see that PHP codes, SQL queries and HTML codes are used intertwined. This type of use is no longer recommended and has been abandoned in almost all PHP projects.
Using the Template/Template engine
Let's continue with the phpBB example. In the phpBB 2.x series, it has tried to separate PHP codes from HTML codes. The result is PHP files that are easier to manage (See: https://github.com/libreajans/phpbb2/index.php). Just look at the readability of the code, not what it does.
PHP does not come with a template engine by default. Various template engines you can use in PHP There. Twig, Blade, Smarty are some of them.
Using Composer
To the setup page of the Twig template engine when you come In Prerequisites, you need at least PHP 7.2.5, it is recommended to install with Composer, and composer require "twig/twig:^3.0"
You can see that there is a line called
Although PHP does not come with a package/library manager by default Compose is in a leading position in this regard. Composer packages are usually configured specifically for the project. If you run the code above after installing Composer, it's in the project folder. composer.json, composer.lock ve Vendor You will see that the named folders are created. Composer keeps its uploaded files in the Vendor folder. You can add, delete or update packages with Composer.
Using classes and writing object-oriented code
Our example for phpBB 2.x if you examine You can observe that the operations are spread over many files, very few functions are used (I could count 40), and hardly any Class/Classes are used. You can define and use repetitive operations or operations that do not repeat, but which are integrated as functions. This process allows you to reuse a part code when needed. It may be easier to think of Classes as containers that hold functions. You can write your functions inside different classes according to what they do. Classes help keep your code portable and reusable when needed. Classes can cause you to contain too many functions or create very long files. After this stage, you actually step into the OOP architecture. Unfortunately, it is impossible to fit PHP and OOP in such a short article. Mehmet Ali Uysal's PHP Training Book in my first article will make your job easier. Of course, there are dozens of articles written on this subject.
Keeping track of PHP versions
You can completely ignore PHP versions prior to 5. The first version of PHP 5 was released in 2004, the last version was released in December 2018, and there is no longer any support for this branch, including security updates. However, it is possible to encounter codes written for PHP 5 version.
Backward compatibility is not observed for PHP major versions. A function that was supported in a previous version may no longer be supported. A code written for PHP 5.5.x version PHP 5.6. may contain incompatibilities. PHP documentation is a variety of documents to guide you through this offers.
The PHP release schedule used to be very vague. Versions and support times are now clearer set status. If you are currently coding with PHP, make sure that the target server supports the corresponding PHP version and you are using the same version in your locale.
Hint: Some servers have the ability to independently select PHP version for each domain. However, this feature is configured on a user-based basis in some cloud servers. In this case, make sure that other domains and projects also support the version you are targeting.
KISS, YAGNI, DRY, SOLID, MCV
KISS a software that recommends approaching the subject in the simplest way, writing code in as few lines as possible is the principle. With this approach, it is sometimes recommended to divide a 100-row operation into smaller functions. YAGNI On the other hand, it is a principle that says not to include things that we do not need in the system. DRY one who advises not to repeat himself is the principle. Many articles written on this topic you can find.
SOLID, It is a whole approach consisting of the combination of 5 principles. Letter S Single Responsibility meaning is coming. It means that a method has only one responsibility. For example, an email sending class should contain only email sending operations. For example, if he sends both e-mail and SMS, he is actually doing two things. Understanding the other principles of SOLID requires a little more OOP experience.
MVC An application design consisting of the combination of the words Model, View, Controller. is the pattern. In the example above, he actually went into this subject a bit by separating the HTML codes from the PHP codes. we became.
To use or not to use PHP Framework
There are many frameworks written for PHP. Frameworks are “the name given to the libraries that combine the PHP codes that developers need for their projects under a single roof”. “It contains the most used modules on the basis of PHP frameworks. Keeping your project organized so you don't have to rewrite key parts like database connections and authorization modules over and over. passing. "
There are many frameworks written for PHP. When choosing PHP Framework, it is necessary to pay attention to what you will use it for, customer requests, version update speed, LTS (Long Term Support) version support. As far as I have observed, Laravel developer is heavily sought and it is the most popular PHP Framework. symfony, phalcon, CakePHP, CodeIgniter, Yii There are many other PHP frameworks such as
Writing code with the framework can narrow your freedom or expand your horizons. Symfony seems to be more successful in backward compatibility. Long supported versions of both Symfony and Laravel called LTS There.
Getting to know free software written in PHP
Lots of CMS (Content Management System) written in PHP There. Ltd., is the most widespread content system in the world and alone dominates 76.4% of the market. Drupal (on 1 million sites) used) and Joomla are the well-known ones. There are also e-commerce sites such as WooCommerce, PrestaShop, OpenCart written in PHP. Do not try to write a new forum system! You can use forum systems such as SMF and phpBB.
Writing secure code
How secure is the code you wrote? Hackers don't need to attack your site to find out. Wide variety of articles for writing secure code with PHP There. Not to trust any data from the user, to verify properly, to clean properly, not to press the screen without cleaning them. is between.
Write clean code
You can write code in many ways with PHP. As teams grow, the issue of code readability becomes more important. To the clean code article for PHP be sure to check it out. There is also a standard called PSR-12 for writing code with PHP. posted. It is always helpful to comply with standards.