9 Things You Can Do With PHP.

One thing that I like about PHP is that you can use it for many different tasks.
So, today let’s take a look at 9 useful things that you can do with PHP.
(You can also find a blog post here).

1. Authentication.
User authentication is one of the most common requirements for a web application.
By using PHP together with a database, you can implement different authentication procedures, from simple ones to complex ones.
Including:
Secure password hashing (thanks to the password_hash() PHP function).
Cookie-based and Session-based authentication.
Two-step authentication (you can send emails, use an HTTP SMS gateway, and so on).
Anti-CSRF protection for login systems.

2. Work with SQL databases.
Web applications store data on SQL databases.
Among all backend languages, PHP is the one with the most complete SQL implementation.

PHP supports many DBMS, including MySQL/MariaDB, Microsoft SQL Server, Oracle, PostgreSQL and even NoSQL databases such as MongoDB.

For MySQL (by far the most used one), PHP provides two different libraries: MySQLi and PDO (you can find my tutorial here).
These libraries provide features such as transactions, multiple-query execution and anti-injection protection through escaping and prepared statements.

3. Create backend systems for web applications.
All web apps need a backend system to work.
You can build this backend using different languages, including Node, Python, Go, and also PHP.
PHP may be a bit more complicated than some of its alternatives, but it provides many functionalities that other languages lack and it often performs better.
PHP is also capable of talking with web apps using JSON.

4. Real-time apps.
Real-time sockets are not PHP’s strong point. In fact, they are probably its most obvious weak point.
That said, you can definitely build a real-time app backend with PHP.

PHP supports websockets via libraries such as Ratchet.
On top of that, you can make PHP work together with other languages like Node.

5. WordPress themes and plugins.
WordPress is a popular web ecosystem which also drives a lot of the Internet PHP usage.
The WordPress core, as well as WordPress themes and plugins, are written in PHP (as far as the server-side code is concerned).

If you are interested in WordPress development, either for fun or for business purposes, then PHP is the main language you need to master.

6. REST and web services
Web services are a way for computer systems to communicate to each other.
Usually, this communication uses data formats such as CSV, XML, and JSON.
PHP is an excellent choice to implement a web service, including REST services that follow the typical RESTful flow:
Read a command from the request string.
Store or retrieve some data.
Send a reply back to the caller.

PHP is also capable of handling complex data types including images, attached files, and so on.

7. Daemons (always-on scripts).
You can use PHP to build always-on processes. That is, scripts that never exit.
I call these processes “PHP daemons” from the Linux terminology (a “daemon” is a process that runs in the background).

PHP daemons are incredibly useful to implement tools such as alarm systems, automatic email sending processes, database maintenance tools and more.
They are also a possible alternative to Cron-fired scripts.

8. Image manipulation.
A somewhat lesser-known feature of PHP is its ability to handle images.
Thanks to the GD library functions, you can create and edit images in various formats such as jpegs, PNGs and GIFs.
You can also perform operations such as resizing, compression and more.

9. Create system and maintenance scripts.
Even if PHP is mostly used for the web, you can use it for system maintenance tasks too.
It is especially useful for database-related operations, such as automatic table cleaning and checking, because of its excellent database support.
It can also perform file and logs maintenance, send email alerts, handle FTP and HTTP uploads/downloads, and more.

Leave a Reply