upd: Carefully, the text contains satire and codebred
The PHP programming language originates in 1995 and is a product of the era of the birth of modern web standards such as http (version 1.0 - 1996), html (version 2.0 - 1995), javascript (1995), url (1990 - 1994). Initially, the abbreviation php had the decoding of Personal Home Page Tools, then transformed into Hypertext Preprocessor or the “hypertext preprocessor”. About using PHP as a preprocessor and will be devoted to several of the following paragraphs. The PHP interpreter allows you to insert into any text a special <? Php?> Tag, with which you can substitute dynamic content into the page, which is very convenient to use inside html documents. The result is immediately fed to a standard output device, known as stdout (for more details, see here ). It is possible to buffer output to demand via the ob_start function, but this will not be necessary for our first html page. The latest html standard, numbered 5, introduced several new tags to simplify the markup, increase the readability and semantic nature of the web (whatever that means). Therefore, we immediately use all the power of HTML5 and write a page template with inserts on the preprocessor in question.
Save this page to the index.html file. The functionality of the blog in its first version will provide for the storage of publications in the form of html pages within a predetermined directory (for example, pages /) and a menu that allows you to go directly to the desired publication. ')
An example of the publication that will be displayed in the blog feed.
In the project root, add the pages / directory and save our article under an arbitrary name, for example, 2018-trends.html.
Now we need a web server to handle incoming http requests from users, and an application server for business logic. In order not to produce unnecessary entities, we will write a small program in the Go programming language, which will also act as a web server and contain the blog code. To transfer user requests from the host program to the preprocessor, we will use the standard input stream (stdin), for data serialization we will use the popular format for data serialization - json.
Now we launch the program for execution through go run and make a request for the page through any browser, for example in the following way:
links2 http://localhost:8000
The result is presented on KDPV.
An inquisitive reader may notice that we lose a lot in performance by running a php process for each request. This moment is easy to optimize using the mechanism of pipes and starting the php process once in the background, but that's another story.