Them hath he filled with wisdom of heart, to work all manner of work, of the engraver, and of the cunning workman, and of the embroiderer, in blue, and in purple, in scarlet, and in fine linen, and of the weaver, even of them that do any work, and of those that devise cunning work.

Exodus 35:35

The language of PHP

You may already be familiar with PHP, the most popular server-side programming language.

Briefly about the language. Founded in 1994 by Rasmus Lerdorf to count visits to his personal website. It was originally written as a simple set of Common Gateway Interface (CGI) binaries written in C. In 1995 Lerdorf rewrote the library by adding new features. The first version supports creating dynamic web pages, working with a database, embedding HTML syntax. The syntax is close to Pearl.

client - server communication
Client-server model

In June 1996, the PHP language was released with its second version, which includes DBM, mSQL, and Postgres95 databases support, cookies, user-defined function support, and much more.

In 1997, Andi Gutmans and Zeev Suraski of Tel Aviv, Israel began work on a new third version, rewriting an underlying parser.

In June 1998, the new version 3.0 was officially introduced, which includes improved syntax, extensibility, and support for the Object Oriented Paradigm.

Version 4.0 was introduced in May 2000, including a fully rewritten “Zend engine”, increased performance and support for multiple HTTP servers.

Version 5.0 came out in July 2004 with a completely rewritten engine, a new object model and many other features.

Version 6.0 of PHP was released in 2005 with built-in Unicode support. This version was abandoned in 2010 due to performance and conversion issues from UTF-16.

In December 2015, version 7.0 of the PHP was released. It contains many improvements and new features, such as return type declarations for functions that complement the existing parameter type declarations, support for the scalar types (integer, float, string, and boolean) in parameter and return type declarations.

PHP 8 was released on November 26, 2020. PHP 8 is a major version and has breaking changes from previous versions. New features and notable changes include:

  – Just-in-time compilation.

  – Addition of the match expression.

  – Type changes and additions.

  – Syntax changes and additions.

  – Standard library changes and additions.

PhpStorm

PhpStorm is an integrated high-end development environment developed by the Czech company JetBrains for more than twenty years. PhpStorm allows the programmer to achieve maximum productivity by providing closely related components with a similar user interface. It provides code completion, refactoring, on-the-fly error prevention, and more features. This product has keyboard shortcuts that are very useful for the programmer.

PhpStorm

PhpStorm main page

Keyboard shortcuts

Shift + Shift brings up a window with all the files from your project, and all kinds of strings can be searched in it. Whether you’re looking for a file name, a variable name, or even a CSS class, this feature will be especially useful.

Shift + O will call the same search window but only for files. It will save you time searching because it searches only in file names.

Shift + F allows you to search the file by opening two micro-windows with the search string and the program code of the file in which the string is located.

Shift + A will search for a specified string in the Actions section. These actions are all possible actions of the development environment. For example, writing, coloring the code, starting a macro, moving the slider on a certain line, etc.

F2 allows error detection in the code. press F2 repeatedly to find all errors.
Command + E shows the most recently used files.

PhpStorm offers many shortcuts that you can see in the product documentation.

 

The code editor

The program code editor is the main component of the integrated development environment. The editor allows you to create, read, edit and delete code. Pressing Alt + Enter opens an action list with all quick-fixes and other actions that are available at the current caret position. This way you can easily get a hint to complete the code. Parameter hints helps programmer to get correct parameters inside methods or functions. The code completion can be also called for class names.

Type-matching completion shows only the types applicable to the current context.

Press Ctrl + Shift + Space and the most suitable suggestion for the current context is highlighted.

You can generate a code needed for a constructor by invoke the generate menu and select “Constructor…”. PhpStorm will generate a constructor code with the needed parameters.

Also you can use a type, which will be automatically imported into your methods. Just point the cursor in the type name and the IDE will popup a notification import bar.

There is another good feature – refactor code. Select the whole code which you want to refactor and use the refactor menu Shift + Ctrl + Alt + T. Next choose from the options  to extract “Variable, Constant, Field, Parameter, Method or Interface”.

refactor

PhpStorm refactoring feature

When you rename a method name, PhpStorm will change the name everywhere this method is used.

PHP 7.4.0 added a new feature, a type declaration for function arguments, return values and class properties.

You will be warned if you use the wrong type in your functions or methods. The editor will notice you for an error in the code as you type, adding a small red wavy line at the location of the error.

PhpStorm has a database browser built in. Go to a database using Ctrl + Tab and select it. Also use F4 to open the database. Then you can use standard SQL queries in your PHP code.

All your code changes you can submit to a Version Control System (VCS), which is also built in feature. Invoke VCS panel with ALT + 9. It shows uncommitted changes and you can commit and push them to the server without leaving the IDE.

Version Control System

PhpStorm Version Control System integration

 

Conclusion

PhpStorm is a great development system that offers rich capabilities for working with PHP and other programming languages. It also includes support for popular CMS such as WordPress, Zend Framework, Magento, Joomla. You can download PhpStorm trial copy from the manufacturer’s website.

 

Eclipse

Eclipse is a free multilingual software development environment that includes an integrated development environment (IDE) and a modular system. It is written in open source mainly in Java under the terms of the Eclipse Public License 2.0. The PHP Development Tools plugin is used to develop projects in the PHP language.

Eclipse install

Eclipse IDE installation process

 

In the beginning you need to create a project and an initial PHP file for the project. A server is required to run the file. Fortunately, Eclipse has a built-in PHP server. Right-click on the file name and select Run as -> Run on Server and select PHP Built-in server. Then select the folder where the PHP is installed.

new php project

New PHP project

new php file

New PHP file

Eclipse php server

Eclipse PHP server

 

Keyboard shortcuts

Useful option is to search in long code. Place the cursor on the variable and press F3 and you will be redirected to the first place of the variable in the code.

Ctrl + space completes the keyword or the name of a selected class or method, finding names also in included external files.

Ctrl + Shift + F arranges the code according to the standard.

Another nice feature is when you want to look up for instance of PHP function. Just put the cursor on the function and press Shift + F2 and will open a new tab with PHP documentation page.

You can add own templates by coping the code choosing drop down menu Window -> Preferences -> PHP Templates. Add new name and paste the code into pattern field. Then type template name + Ctrl + space and your code is here.

 

The code editor

When you start typing in the editor, the development environment automatically offers tips for completing the code, as well as descriptions of each available class, function, or method. For example, create a variable and assign a value. Then start typing the name and the editor will show it. This feature is available even for classes in the current code. For example, if you create a class object and want to use its method, the editor will offer a choice of all its methods.

You can also choose from the built-in functions on the right side of the dialog box.

Annotations “@” help the programmer in choosing a keyword.

If you add a comment starting with TODO word and save the project, later you can see the mark bottom in the tasks tab. Another useful keyword is FIXME, which also popup in the task tab but it has a red exclamation mark.

Conclusion

Eclipse is a free and easy-to-use software IDE which can be used on multiple platforms such as Windows, Linux, macOS. It supports syntax highlighting, code completion, automatic code generation, debugger, integration with Source Code Management, several compilers, repositories through Git. Integration with third party modules (Spring Tools, TestNg, Maven, Git, Eclipse Web Developer Tools, etc.) trough Eclipse Marketplace Client for installing solutions listed on Eclipse Marketplace is a great advantage.

I recommend Eclipse for use by beginners and professionals as well.

PHP Tools for Visual Studio

PHP tools turns Visual Studio into a powerful PHP development environment by adding support for editing and debugging. The company developer – Devsense offers a variety of packages for individual developers and organizations. Note that PHP Tools does not support Visual Studio Express editions!

PHP Tools is an extension to Visual Studio to expand its capabilities for developing PHP projects. Assists the developer by following the conventions. Analyzes code as you write, suggests completion, error correction, and formatting.

PHP tools for visual studio

Keyboard shortcuts

PHP Tools follows the Visual Studio keyboard scheme. You can change the shortcuts from Menu -> Tools -> Options by expanding the Environment node, and choosing Keyboard.

Most useful keyboard shortcuts

Pressing Tab at any time will offer a block of reusable code filled with code snippets.

Press Ctrl + Q to perform Visual Studio search.

You can Choose Ctrl + E, V to duplicate a line of code without having to copy it.

You can format entire code page by pressing Ctrl + K, Ctrl + D or selection Ctrl + K, Ctrl + F.

Insert snippet Ctrl + K, Ctrl + X.

Find all references Shift + F12.

Extract method Ctrl + R, Ctrl + M.

View designer Shift + F7.

Run code analysis on solution Alt + F11.

Breakpoints Ctrl + Alt + B.

Dom explorer Ctrl + Alt + V, D.

Default keyboard shortcuts

Default keyboard shortcuts

The code editor

The Visual Studio main window is divided into several areas – menu bar, status bar, editor area, side panel containing the Solution Explorer, and various toolbars. As you enter code in the editor, IntelliSense information, such as List Members, Parameter Info, Quick Info, Signature Help, and Complete Word, appears. By switching IntelliSense to suggestion mode, you can specify that IntelliSense options are inserted only if you explicitly choose them.

PHP tools editor

PHP tools editor

The editor is fast and predicts letters, code fixing, supports daily programmer routines such as emphasizes occurrences of symbols and renaming. Using smart tag feature you can change occurrences of all uses of a given symbol, while editing. There is an option to display a preview of a individual occurrences and exclude them from the set.

Individual occurrences

Check for individual occurrences

The editor also checks for a long range of errors. This means for syntax and semantic errors. For example, the tool checks for a given function return requested value and value type. It looks for unreachable code, for infinite loops which can cause program freeze.

Another useful feature is the reminder for unused or uninitialized variables. The editor highlights such variables with a green wavy line. This feature helps the programmer even if he confuses the data type of a function arguments or their number.

Code snippets may prevent errors and boost your productivity. They popup when you type a code. Before a function the tool analyzes the code and by typing /** it will generate a comment with the parameters used and a return type. Documentation comments are highlighted and their syntax is checked.

Extending classes by a new Interface is made easier by smart tags with a command implement interface or override abstract methods. At the end of the classes body empty implementations of missing methods are added. Also added TODO comments inside the body to remind the programmer.

In the editor window, the navigation bar helps by display the classes and methods in the current context. It allows you to jump directly to declaration and definition inside the editor window.

Class view

Class View window

Class View window organizes the declarations according to Namespaces. For each class shows its members.

You can also find all occurrences of a given symbol using the command “Find All References”.

Find all references

Find All References command

In the editor you can use command “Peek Definition” which opens a Peek Window, which shows a declaration under the cursor.

Type analysis is a unique feature in the PHP Tools for Visual Studio. Intellisense remembers dynamically declared class properties and their types, monitors what programmer types and offers code completion. This feature empowers work process.

This IDE also integrates Composer tool. It automatically manages and updates all installed packages.

Composer integration

Composer integration

A mandatory function for every modern development environment is a Debugger. This IDE manages the web servers and allows the developer run the project in any browser and debug it for errors. It allows you to set breakpoints, runs and stops the program at these points. You can easily investigate the program execution flow. The debugger lets you track the execution step to the next line, step into and step out the line. In the bottom window you can inspect every variable during the execution of the program. Also supports inspecting complex structures such as Arrays, Call Stacks, HTML code and JSON objects.

Debugger

Debugger in PHP Tools for Visual Studio

Conclusion

I have no hesitation in recommending this to any PHP developer, because it gives a comfort of developing in PHP. I like the integrated PHP Manual, the rich visual debugging features – inspecting variables, watches, multiple session debugging. Devsense offers a great support and much information on their forum.

PHP Sandbox

PHP Sandbox can be called a test tool for PHP code. This free tool provides the ability to write and test your code through any web browser. It is a part of The Online PHP Functions project, which provides extensive information on programming in this language, such as tutorials, explanations and useful features. The creator has decided to provide access to the basic functions of the language. Some features are disabled by default for security reasons. Features that require access to the system, disk, or network are prohibited. The design is minimalist and clean, offering the opportunity to test your application on almost all versions of the PHP language. PHP Sandbox offers the ability to save and share code with others. The editor supports code coloring and basic syntax checking.

PHP sandbox

PHP Sandbox

I personally highly recommend this small and handy tool to any programmer. See also the rest of the project – PHP Functions, Custom functions, Tutorials, PHP Benchmarks.

Ideone

Ideone is another online based tool for writing and testing code. This project supports more than sixty programming languages, including PHP! You can view the page with examples in different programming languages ​​and the page with codes sent by users. The creators of Sphere Research Labs have done a pretty good job of realizing all the possibilities. The editor is clean and easy to use, supports line numbering, syntax highlight, error correction. You can use labels to organize your codes. You can share the code, hide it, download it in the appropriate file format or fork it.

Each user receives a unique URL to share their program. Also the code can be shared on popular web platform like Facebook, Twitter, ВКонтакте etc.

ideone

ideone main window

A window is provided for entering input parameters to the program. The output window for the result shows the execution time and the memory used. Allowed values:

  • compilation time: 10 seconds;
  • execution time: 5 seconds (for not logged in users) or 15 seconds (for registered users);
  • memory usage: 256 MB;
  • limit for the source code 64 KB;
  • create up to 15 processes. It means, for example, that you can use together up to 14 pipelines in the Bash.

This platform has been used by me for a long time. I am impressed by the variety of languages supported. I decided to use the platform for the examples listed in this blog. I recommend everyone who wants to be involved in programming to start the journey from ideone.

 

Recommended References

Last modified: July 8, 2022

Author

Comments

Write a Reply or Comment

Your email address will not be published.