Mastering The Faster Web with PHP, MySQL, and JavaScript
eBook - ePub

Mastering The Faster Web with PHP, MySQL, and JavaScript

Develop state-of-the-art web applications using the latest web technologies

Andrew Caya

Share book
  1. 278 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Mastering The Faster Web with PHP, MySQL, and JavaScript

Develop state-of-the-art web applications using the latest web technologies

Andrew Caya

Book details
Book preview
Table of contents
Citations

About This Book

Make web applications run faster by using advanced PHP, SQL and JavaScript techniques

Key Features

  • Use a customized PHP stack to create efficient data-driven web applications
  • Ensure seamless implementation of a JavaScript & HTML 5 CSS based frontend and PHP based backend.
  • Learn about problem identification, best strategies, and UI design patterns as well to build a clean, fast web application

Book Description

This book will get you started with the latest benchmarking, profiling and monitoring tools for PHP, MySQL and JavaScript using Docker-based technologies. From optimizing PHP 7 code to learning asynchronous programming, from implementing Modern SQL solutions to discovering Functional JavaScript techniques, this book covers all the latest developments in Faster Web technologies. You will not only learn to determine the best optimization strategies, but also how to implement them.

Along the way, you will learn how to profile your PHP scripts with Blackfire.io, monitor your Web applications, measure database performance, optimize SQL queries, explore Functional JavaScript, boost Web server performance in general and optimize applications when there is nothing left to optimize by going beyond performance.

After reading this book, you will know how to boost the performance of any Web application and make it part of what has come to be known as the Faster Web.

What you will learn

  • Install, confgure, and use profling and benchmarking testing tools
  • Understand how to recognize optimizable data structures and functions to effectively optimize a PHP7 application
  • Diagnose bad SQL query performance and discover ways to optimize it
  • Grasp modern SQL techniques to optimize complex SQL queries
  • Identify and simplify overly complex JavaScript code
  • Explore and implement UI design principles that effectively enhance the performance
  • Combine web technologies to boost web server performance

Who this book is for

The audience for this book would be PHP developers who have some basic knowledge of PHP programming and Web technologies. JavaScript programming knowledge is not necessary.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Mastering The Faster Web with PHP, MySQL, and JavaScript an online PDF/ePUB?
Yes, you can access Mastering The Faster Web with PHP, MySQL, and JavaScript by Andrew Caya in PDF and/or ePUB format, as well as other popular books in Informatique & Développement Web. We have over one million books available in our catalogue for you to explore.

Information

Year
2018
ISBN
9781788397711

Continuous Profiling and Monitoring

In this chapter, we will learn how to install and configure profiling and monitoring tools that will help you easily optimize PHP code in a continuous integration (CI) and a continuous deployment (CD) environment.
We will start by installing and configuring a basic Blackfire.io setup in order to easily and automatically profile code when committing it to a repository. We will also learn how to install a TICK Stack in order to continuously monitor our code's performance after its deployment on a live production server.
Thus, in this chapter, we will cover the following points:
  • Installing and configuring the Blackfire.io agent, client and PHP extension
  • Integrating the Blackfire.io client with Google Chrome
  • Integrating the Blackfire.io client with a known CI tool like Travis
  • Installing and configuring a complete TICK Stack with Grafana

What is Blackfire.io?

As stated on the official Blackfire website (https://blackfire.io), Blackfire empowers all developers and IT/Ops to continuously verify and improve their app's performance, throughout its life cycle, by getting the right information at the right moment. It is, therefore, a performance management solution that allows you to automatically profile your code and set performance standards through assertions throughout your application's life cycle, especially in the development phase. Blackfire.io is a tool that makes what Fabien Potencier calls performance as a feature possible, by making performance tests a part of the development cycle from the very beginning of a project.

Installing and configuring Blackfire.io

Installing and configuring Blackfire.io means setting up three components: the agent, the client and the PHP Probe. In the context of this book, we will be installing Blackfire.io inside our Linux for PHP container. To get more information on installing Blackfire.io on another operating system, please see the following instructions: https://blackfire.io/docs/up-and-running/installation.
We will start by installing the Blackfire agent. On the container's command-line interface, enter the following commands:
# rm /srv/www
# ln -s /srv/fasterweb/chapter_2 /srv/www
# cd /srv/www # wget -O blackfire-agent https://packages.blackfire.io/binaries/blackfire-agent/1.17.0/blackfire-agent-linux_static_amd64
Once the download is completed, you should see the following result:
Blackfire agent download is done
If so, please continue by typing these commands:
# mv blackfire-agent /usr/local/bin/ # chmod +x /usr/local/bin/blackfire-agent 
Now, we will copy a basic agent configuration file to our etc directory:
# mkdir -p /etc/blackfire # cp agent /etc/blackfire/ 
Here is the content of the file we just copied. It is a basic configuration file, as suggested by the Blackfire team:
[blackfire] ; ; setting: ca-cert ; desc : Sets the PEM encoded certificates ; default: ca-cert= ; ; setting: collector ; desc : Sets the URL of Blackfire's data collector ; default: https://blackfire.io collector=https://blackfire.io/ ; ; setting: log-file ; desc : Sets the path of the log file. Use stderr to log to stderr ; default: stderr log-file=stderr ; ; setting: log-level ; desc : log verbosity level (4: debug, 3: info, 2: warning, 1: error) ; default: 1 log-level=1 ; ; setting: server-id ; desc : Sets the server id used to authenticate with Blackfire API ; default: server-id= ; ; setting: server-token ; desc : Sets the server token used to authenticate with Blackfire API. It is unsafe to set this from the command line ; default: server-token= ; ; setting: socket ; desc : Sets the socket the agent should read traces from. Possible value can be a unix socket or a TCP address ; default: unix:///var/run/blackfire/agent.sock on Linux, unix:///usr/local/var/run/blackfire-agent.sock on MacOSX, and tcp://127.0.0.1:8307 on Windows. socket=unix:///var/run/blackfire/agent.sock ; ; setting: spec ; desc : Sets the path to the json specifications file ; default: spec= 
Then, create an empty file that will be used as the agent's socket:
# mkdir -p /var/run/blackfire # touch /var/run/blackfire/agent.sock 
Finally, we will register our agent with the Blackfire service:
# blackfire-agent -register 
Once you will have entered the last command, you will have to supply your Blackfire server credentials. These can be found in your Blackfire account at: https://blackfire.io/account#server. Once you have entered your credentials, you can start the agent by entering the following command:
# blackfire-agent start & 
After starting the agent, you should see the agent's PID number. This tells you that the agent is listening on the default UNIX socket that we created previously. In this example, the agent has a PID number of eight (8):
Blackfire agent process ID number is displayed
Once the agent is installed and configured, you can install the Blackfire client. We will install and configure the client by issuing the following commands. Let's start by downloading the binary:
# wget -O blackfire https://packages.blackfire.io/binaries/blackfire-agent/1.17.0/blackfire-cli-linux_static_amd64 
After the download is done, you should see the following message:
Blackfire client download is done
You can now proceed to configure the client. Enter the following commands:
# mv blackfire /usr/local/bin/ # chmod +x /usr/local/bin/blackfire # blackfire config 
After entering the final command, you will have to supply your Blackfire client credentials. These can also be found in your Blackfire account at the following URL: https://blackfire.io/account#client.
The final step in order to run Blackfire.io on our server is to install the Blackfire Probe as a PHP extension. In order to do this, please start by downloading the library:
# wget -O blackfire.so https://packages.blackfire.io/binaries/blackfire-php/1.20.0/blackfire-php-linux_amd64-php-71.so
Once the download is completed, you should get this confirmation message:
Blackfire probe download is done
You can then copy the shared library file into your PHP extensions directory. If you...

Table of contents