Strengthening PHP settings in Obsidian and the new PHP Composer
PHP, standing for “hypertext processor”, started out as a small open source project that evolved as more and more people found out how useful it was. Today, it is one of the most widely used scripting languages in the world. It’s particularly popular for web development since it can be easily embedded into HTML pages.
PHP is so popular and effective that you’ll find it at the core of the biggest content management platform, WordPress. As well as behind the largest social network – Facebook. One of the things that makes PHP so great is that it’s powerful, flexible, and easy to use. It runs on various platforms, is compatible with most servers, and everyone from expert developers to beginners and hosting managers can work with it.
Plesk provides full support for the PHP scripting language. Including support for multiple PHP versions and handler types out of the box. As part of Plesk Obsidian, our latest product release, we introduced PHP Composer. A new extension that allows you greater control over your PHP settings, ensuring they’re as strong as can be.
In this article, we dive into the new Plesk Composer extension. Looking at how you can use it to better manage PHP settings for your domains and subdomains directly from Plesk’s control panel.
The New PHP Composer Extension
PHP Composer is an extension that helps you find, install, and update library packages that your PHP project depends on. Starting from Plesk Obsidian, PHP Composer is available by default as a Plesk extension.
The tool is ready to go, out of the box. Allowing users access to all the most important operations within the Plesk UI. This also means you don’t need to install obligations or manually update to the latest versions. The PHP Composer does it all for you.
There are many benefits to using the new PHP Composer. To give you a better idea how it can strengthen your PHP settings, here’s an overview of its core features.
Use PHP Composer without SSH access
There’s now no need to gain SSH access to execute the most useful Composer actions. Using PHP composer. You can set up environment variables, edit your composer.json file, run the Install and Update commands. All from the Plesk UI.
Install and update dependencies with one click
Instead of having to remember all the commands and options to run to install dependencies, the Plesk Composer takes care of it with a click of a button. You’ll also soon be able to use it to perform test runs before executing dependencies, to ensure they don’t break your production site.
Review installed dependencies before updating
To maintain a secure website, it’s important to update dependencies. But doing so can lead to a broken site. With Composer, you can review installed dependencies and decide if it makes sense to update them before doing so. Soon you’ll also be able to use Composer to identify security issues with the installed version.
Get the right PHP version automatically
You want to make sure your website is using the right PHP version. PHP composer ensures your website automatically uses the PHP version specified in composer.json. Soon Composer will also allow you to choose the correct PHP version and handler. Just log in via SSH and run the “php” command.
How to Run PHP Composer
As mentioned, Plesk Obsidian comes with PHP Composer already installed and compiled with the most popular modules. However, if you need to install some additional libraries, you can connect to a Plesk server via SSH (Linux) / RDP (Windows Server).
Instead of running the default command:
# composer [options] [arguments]
use the following commands instead:
X.X (XX for Windows Server) should be replaced with an installed PHP version provided by Plesk (5.6, 7.0, 7.1, etc).
On CentOS/RHEL-based distributions, use the command:
# /opt/plesk/php/X.X/bin/php /usr/lib64/plesk-9.0/composer.phar [options] [arguments]
On Debian/Ubuntu-based distributions, use the command:
# /opt/plesk/php/X.X/bin/php /usr/lib/plesk-9.0/composer.phar [options] [arguments]
on Windows Server, use the command:
c:\> “%plesk_dir%Additional\PleskPHPXX\php.exe” “%plesk_dir%Additional\Composer\composer.phar” [options] [arguments]
Customizing PHP Settings in Plesk Obsidian
Customizing your PHP settings is now super simple. Whether you want to alter one domain, a selection of domains assigned to a specific plan, or all your domains. To adjust PHP setting for a domain, go to:
Domains > example.com > PHP Settings
You can then adjust the PHP settings according to your needs and apply the changes.
To customize the PHP settings for domains that are assigned to a specific service plan, go to:
Service Plans > plan_name > PHP Settings
You can then adjust the PHP settings according to your needs and apply the changes by clicking Update & Sync.
Finally, you can customize PHP settings for all domains by going to:
Tools & Settings > PHP Settings > click on a required PHP version (any application) > switch to the php.ini tab.
You can then adjust the values for existing PHP parameters or specify your own. Once you finish, apply the changes.
Managing PHP Dependencies with Composer
To store the list of modules for a project, PHP Composer uses two files. Composer.json – to list libraries on which your project depends directly. And composer.lock, to list all libraries on which the libraries in composer.json depend directly and indirectly.
Plesk offers two ways to use Composer: Through the command line, and through Websites & Domains > Applications. Below are a few of the main ways you can use PHP Composer to manage dependencies.
For more detailed information, you can refer to the PHP Composer documentation.
Manage PHP Project Dependencies with Composer
To manage dependencies, you can find all applications that have composer.json by clicking Scan in the Applications section. The applications will appear in the list. The commands below are available only for applications with the composer.json file.
You can use PHP Composer to install all modules necessary for your project by going to: Websites & Domains > Applications > Manage My Applications. Click the application name in the list, and finally select Install Dependencies.
You can update module dependencies by running Websites & Domains > Applications > Manage My Applications > clicking the application name. And then selecting Update Dependencies.
To manually edit dependencies, you can select the Edit Configuration button and open up composer.json in Plesk’s Code Editor.
Remove Dependencies Management from Your App
By clicking Remove, the application will no longer appear in the list of applications in My Apps. However, the composer.json and composer.lock files will remain in the application directory. So you can add the application to the list by clicking Scan.
Have you tried the new PHP composer yet? Let us know your feedback and suggestions in the comments!
How useful was this post?
Click on a heart to rate it!
Average rating 5 / 5. Vote count: 1
Oh no, sorry about that!
Let us know how we can do better below
Thanks for your feedback!