Code-Hero: PHP

Using PHP with Code-Hero

👋 Welcome to the Stackhero documentation!

Stackhero offers Code-Hero, a complete development platform to code in seconds:

  • Code from anywhere: Use any device, be it a desktop, phone, or tablet, without requiring any software installations.
  • Integrated VSCode experience: Work with a customised version of VSCode directly through your browser, featuring a fully functional terminal.
  • Comprehensive toolset: Benefit from a pre-configured environment with tools and languages like Docker, Git, Zsh, Node.js, Go, Python, Ruby, and more.
  • Seamless connectivity: Access your development applications via HTTPS on a public domain, mimicking production conditions. This setup supports webhooks and external integrations effortlessly.

Experience the efficiency and convenience of Stackhero's Code-Hero development cloud solution. It takes just 5 minutes to get started! Simplify your development processes and save valuable time today.

Code-Hero comes with asdf, a utility that allows you to easily select the PHP version you need.

By default, the latest PHP version is installed. You can check the installed version by running:

php -v

If you want to use a different PHP version, follow these steps:

  1. Update all plugins:

    asdf plugin update --all
    
  2. List all available PHP versions:

    asdf list all php
    
  3. Install the desired version:

    asdf install php <VERSION>
    

After installing the desired version, decide whether you want to use it globally or locally:

  1. To use it globally (across all directories), run:

    asdf global php <VERSION>
    
  2. To use it locally (for the current directory only), run:

    asdf local php <VERSION>
    

    This command creates a .tool-versions file in the current directory containing the chosen version information.

To verify which version is active, run:

php -v

Adding PHP extensions is straightforward. For example, to install the AMQP extension (which is useful for connecting to a RabbitMQ server), follow these steps:

  1. Install the extension using PECL:

    pecl install amqp
    
  2. Add the extension to your PHP configuration by appending it to your php.ini file:

    echo "extension=amqp.so" >> $(asdf where php)/conf.d/php.ini
    
  3. Check that the extension is enabled:

    php -i | grep amqp
    

To list all currently installed extensions, run:

php -m