PHP
| My PHP articles | |
| Other PHP articles | |
| About the PHP language | |
| Application areas | |
| Additional features |
| PHP session locking | |
| Installing PHP frameworks | |
| Installing Yii | |
| Installing Symfony | |
| Installing Laravel | |
| Profiling PHP sites | |
| XDebug - debugging and profiling php code |
About the PHP language
PHP: Hypertext Preprocessor — originally Personal Home Page Tools — is a general-purpose
scripting language, widely used for web application development.
Today it is supported by the vast majority of hosting providers
and is one of the leading languages for building dynamic websites.
The language and its interpreter (Zend Engine) are developed by a group of enthusiasts
as an open-source project.
The project is distributed under its own license, incompatible with the GNU GPL.
Application areas
In web programming, particularly server-side,
PHP is one of the popular scripting languages
(alongside JSP, Perl and the languages used in ASP.NET).
Its popularity for building websites comes from a large set of
built-in tools and extra modules for web application development.
The main ones:
automatic extraction of POST and GET parameters, as well as web
server environment variables, into predefined arrays;
interaction with many different database management systems
through extra modules
(MySQL, MySQLi, SQLite, PostgreSQL, Oracle (OCI8), Oracle, Microsoft SQL Server,
Sybase, ODBC, mSQL, IBM DB2, Cloudscape and Apache Derby, Informix, Ovrimos SQL,
Lotus Notes, DB++, DBM, dBase, DBX, FrontBase, FilePro, Ingres II, SESAM,
Firebird / InterBase, Paradox File Access, MaxDB, PDO interface), Redis;
automated sending of HTTP headers;
working with HTTP authorization;
working with cookies and sessions;
working with local and remote files, sockets;
handling files uploaded to the server;
working with XForms.
Today PHP is used by hundreds of thousands of developers. According to the TIOBE ranking, based on search engine data, in May 2016 PHP was 6th among programming languages[14]. The largest sites using PHP include Facebook, Wikipedia and others.
It is part of LAMP — a widespread software bundle for creating and hosting websites (Linux, Apache, MySQL, PHP).
Additional features
The language natively supports
HTTP Cookies
, following Netscape standards. This allows setting and reading small chunks of client-side data.
Cookie handling is organized through sessions (sessions). Sessions expire (data is deleted afterwards), and can store and edit various data types, including serialized ones - passed through serialize (happens automatically), PHP objects.
Creating GUI applications
PHP is not aimed at application development, but there is a need for interfaces to configure servers, run continuously, debug scripts, manage local and test servers, etc. That is why solutions to this problem emerged.
Extensions
The main implementation approach is extensions, which are effectively wrappers over UI libraries.
Broadly, extensions fall into three kinds: php extensions, FFI wrappers (extensions using system functions via FFI) and console wrappers (extensions talking to php through the command-line interface - CLI)
The first kind includes: WxPHP
(Windows,
Linux
, Mac OS X), Winbinder (Windows)
The second kind includes: Win32Std, Tk (implementation for
Python
)
The third kind includes: PHP-UI, PHP-XCB
There are also extensions that wrap both ways — for using other languages to write php extensions and vice versa - PSV Component Library, a project of three sub-projects:
PHP4Delphi (main project, author - Sergey Perevoznyuk):
Implements connecting php with a Delphi program through WinAPI
actively developed since 1999, but not updated for 4 years due to the author being busy, which spawned forks - branches with unofficial updates, viewable at https://github.com/perevoznyk/php4delphi/network, one of them being PHP4Lazarus.
PHP extensions development framework project (secondary):
Tools for creating php extensions, VCL components; although the author shelved this project, it is an integral part of PHP4Delphi, whose base components are needed to build applications
php4Applications project (secondary) - an extension for easy use of php in other languages, also based on PHP4Delphi (gives access to macros, which simplifies using php and removes the need to write your own wrapper).
Development environments
Full GUI PHP development environments also exist:
DevPHP (IDE)
The pioneer in this category is the DevPHP-IDE studio, which used Kylix (Delphi) as the interface base and php-cli to build user programs.
It included a code editor, several tools and visual preview of
HTML pages.
First presented in 2002, it now has 3 stable versions, but development stopped — after the lead developer died in a car crash.
CodeGear Rad Studio (Extension)
After DevPHP IDE came an extension - a component set for CodeGear Rad Studio 2009 based on php4delphi with some improvements (web elements, inspector, debugger); it lasted four versions, the second of which joined the paid Rad Studio 2010 extension: scripts could be used, web component styles set, styles and web pages previewed before building the program, a local server run, the program built as a standalone application and code debugged. With Delphi XE the extension became RADPHP Xe. Later the studio itself became Embarcadero Delphi, and work on the extension paused indefinitely.
DevelStudio (RAD)
In 2009, development started on an environment for building graphical PHP applications based on php4delphi, later joined by Rostislav Romanov. It was named PHP DevelStudio, first published version 0.1.7. DevelStudio had few toolbox components and ran on outdated PHP 4. Version two added PHP 5 support. Threads were added, many changes and improvements made. Program build code became closed, previous versions and forum posts were deleted to hinder wrongdoers.
DevelStudio version two also received the AlphaControls component set, which got it used for building malware because of its simplicity. Popular antiviruses of the time (MacAffee, AVG, Avira) started flagging any DevelStudio-compiled program as a virus.
After some time the AlphaControls author complained to the DevelStudio developers, and the component set was fully removed from the environment — but survived in the already released version, which could not be removed from the forum this time.
As of 2012 the last version came out - 3.0.2, with a new component set including the Chromium browser instead of IE, which drew the attention of web developers and users of the "Algorithm" environment. At the time compiling programs in "Algorithm" was paid, so DevelStudio as a new free environment won over most of the audience.
In 2014 the community made first attempts to revive the environment. In late 2018 the source code was restored and is available in this GitHub repository.
In 2019 the community asked the DevelStudio creator to change the distribution policy, making it open for updates and edits. Following complaints about missing links to used libraries (DCEF, PHP4Delphi, TSizeCtrl, SynEdit) the forum was deleted, and one environment description page now redirects to the site homepage. Since then DevelStudio officially belongs to the community.
PHPQt (IDE)
In 2015 Alexander Kazantsev started studying interface development algorithms and created the php_qml extension, enabling QT library widgets, but supporting only one platform - Windows.
That started PHPQt development; the first versions drew little attention from web developers, so the author began improving the extension in depth.
On July 28, 2015 the first project compiler was published; at the time a simple script runner attaching php code to a stub (like DevelStudio), dependent on the Windows API; almost all widgets and multithreading were already supported at this stage, with light php code optimization. From then on the engine was called PQEngine,
On August 3, 2016 the fifth application compiler version (PqBuilder) came out, moved to the PlastiQ base with support for the then-newest php 7; projects got a more complete compiler and no longer needed PqEngine.dll next to the executable — instead visual libraries were added dynamically as files rather than sewn into PQEngine.dll. This was done for compatibility with other systems and original Qt libraries.
With version six the project became a Qt Studio add-on, and the compiler became merely a code optimizer before the final program build. A full interface editor appeared, code editor hints, and documentation started. From then on the PqStudio environment was announced, but its development did not go far.
DevelNext (IDE)
In parallel, the lead DevelStudio developer started creating a "reincarnation" of the previous environment - DevelNext; the studio took the Swing graphics library and JavaFX as a base, producing a brand-new environment with CSS support but without full PHP support - the project was based on its own jPHP language, also interpreted, and lasted in this form until version 17 (17-RC1), where it was abandoned.
In version 16 the DevelNext environment gained php 7 support and enthusiasts extended it for OS Android development.
Currently the author and enthusiasts are working on version 19 (previously the 17th).
Connecting PHP to a project
Extensions also exist for the geometrically opposite use - connecting PHP to a project in another programming language:
Phalanger (C#) - php 5.4 to 7, Peachpie (C#) - php 7,
PHP4Delphi(Lazarus, Delphi, C#, C, C++) - php 5.6,
JPHP(Java) - php 7.0,
PHPly(Python) - php 5.6
- PHP course: zero to hero in 50 lessons
- What is new in PHP 8.0 vs PHP 7
- What is new in PHP 8.5 vs PHP 8.0
- Creating rules in .htaccess
Article author: Andrei Olegovich