I continue the series of articles about site building for a novice web programmer. In the previous article, we talked about concepts such as a dynamic site in PHP . In this post, I propose to figure out which engine for the site is better . Of course, it is impossible to answer this question unequivocally, and there are reasons for that. All novice webmasters ask only one question: “Where can I find ready-made instructions for creating the perfect site?”, And they can be understood, because only a web programmer who is just starting out does not want to get into trouble by studying outdated or “wrong” technology.
It is difficult for a beginner to realize that each project is, in fact, unique. The method of performing each professional task is influenced by a large number of factors. But not everything is so scary, for typical tasks there are always ready-made solutions, all kinds of content management systems (better known as CMS). To be honest, many pros rarely write from scratch, often using ready-made script collections and popular frameworks. But a professional is not obliged to reinvent the wheel, he is able to critically evaluate someone else's program code and successfully apply it in his project. Today I will not advocate for any particular engine, comparing them trying to find out which engine is best for your site, but simply talking about existing web technologies and how to use them.
The very concept of “engine for a site” is very broad, it can be either one index.php control script, in which files containing static pieces of HTML code are collected (“included”) by the standard PHP include() function, or more complex programs, CMS is one of them. I will give a simple example. The content of the following parts of the site: "header", block with menu, block with content and "footer" - is taken out in separate files, which are assembled into a single whole in index.php. Files (pages) with content, if there are many of them, can be moved to a separate /include folder and “included” from it using an array, while for each page you can create unique headers and meta-data specified in the config.php configuration file .
This is an approximate version of creating your own engine for the site. I don’t give a code example, because at this stage it is important for you to understand only the principle of organizing the engine.
About the role of the DBMS in the process of creating a site
Very often, for convenient handling of large amounts of data, programmers (and not only) use databases. In the case of a website, textual or graphical content is often placed in a database that is stored on a remote server. An example of a DBMS (database management system) is MySQL. You will probably get acquainted with MySQL (or PostgreSQL) when organizing a hosting space for your site, using a more or less complex script, or installing a CMS system . But now we are not talking about hosting parameters, now we are talking about technology.
Technologically, this is so: the data located in the database is created, modified and managed using SQL queries, which, in turn, are created based on the SQL structured query language. But this is in its purest form. The PHP language, in turn, is endowed with various functions for working with MySQL. Through a php script, we can connect to the MySQL server and select a database (mysql_connect(), mysql_select_db()), pass sql queries (mysql_query()), process query results (let's say mysql_fetch_array()) and terminate mysql connections.
A database server is understood not only as a separately installed machine that acts as a MySQL server, but also as a functional server. Roughly speaking, one piece of hardware can serve as a web server (apache, nginx), and a mysql server, etc. But we will talk about this in an article on choosing a hosting. As you already understood, such technologies are used when creating / managing the site as a whole. It should be noted that web programmers sometimes use databases based on text files, but that is another story.
Which is better: naked PHP or a framework?
Probably, such a topic is not entirely for beginners, the topic is quite "holivar", but it will not be superfluous to have some ideas in order to correctly determine the choice of the best engine for your site. If we take PHP as a basis, and there are other scripting programming languages, then it should be said that many programmers use the so-called MVC frameworks based on the PHP language. Using frameworks is a specific approach to designing and building web projects. Zend Framework, Symfony, CodeIgniter, Kohana and many others are built for rapid development of PHP applications, but this is not the only criterion. However, you will also have to learn the framework itself. Many frameworks, like a kind of “add-on” over PHP, are demanding on server resources. Experts argue a lot and stubbornly on the topic: “What is better to use as an engine for a site?”. Some argue that if there is PHP, then why a framework, why an intermediary "eating a piece of the resource pie", referring to the fact that the largest and most popular sites are written in pure PHP. Others consider development using the framework more advanced and convenient - the next step in the development of a PHP programmer. Some believe that when using the framework, under certain conditions, you can even "win" in performance. PHP itself can work in different modes (for example, mod_php), which can also affect performance.
Code by yourself or choose a solution from the "box"?
When creating a site in PHP or PHP + framework, you need to be aware that the level of programming is different for everyone, that simply knowing the syntax of the language is not enough to create a powerful site. There are a lot of criteria for a well-executed (from a programmatic point of view) site (security, functionality, performance, etc.) and taking into account all the nuances is often beyond the power of a beginner. There are specialists who deal exclusively with testing new software projects, this is not a simple procedure, it is very important when creating a site using a unique program code.. All this is not in vain, and this is what experienced programmers remember when they use the dissonant phrase “shit code” in relation to the next crooked module for a popular CMS or some unsuccessful open source project. All this suggests that you can decide on the best engine for your site only if you select the engine for the specific features of your network project.
Nothing is perfect and it's no secret that even many CMS (distributed under different licenses, including commercial ones) do not always (or not completely) meet the above criteria for the quality of the program code. However, CMS are written and updated by highly qualified programmers (for the most part), such systems are tested at the design stage and by the community, which reduces the chances of running into problems of a different nature. For commercial CMS extensions (components, modules, plug-ins) are created by a centralized group of developers of the CMS itself or one of the groups, but extensions for open source CMS can be created by anyone and in any way. Often, it is in the extensions that the “shit code” is observed - with all the consequences. Once, one of my sites based on CMS Joomla was hacked due to the fault of the hosting provider (yes, hosters also sin with "crookedness"), but the malicious code was placed precisely in third-party extensions (popular and with a good reputation). In general, there are more articles on this topic on the Internet than “pimples on the body of a hippopotamus”, but understanding will not come immediately, because all this is already from the field of programming, which not all the creators of the site own. Not everyone needs it. Now it's time to talk about CMS systems in more detail, my next article is dedicated to them -content management systems (CMS) .


