Skip to main content

🚀 Introduction

  • Before you begin, make sure you have PHP on your system. If you don’t have them yet, you can download them from the official PHP website.
  • Next, you will need to create an account on Square Cloud, which can be done through the login page. You can use your email, GitHub, or both to create the account.
  • Finally, you need to have an active paid plan on your account. You can view our plans and purchase one according to your needs here.

⚙️ Creating the squarecloud config file

Learn about: how to make the configuration file for Square Cloud.

The squarecloud.app file is a configuration file that will be used to configure your application; it will be used to define the name, description, version, main file, among other things.

📄 Required Files

  • index.php (Example of main file).
  • composer.json (*Optional dependency file).
  • squarecloud.app (a file containing your Square Cloud configuration).

▶️ Start Application

  • If the START field is not defined in the configuration file, a local PHP server will be started using the php -S 0.0.0.0:80 command. If the START field is defined in the configuration file, the value in the START field will be executed directly. For more information on configuration file parameters, visit configuration parameters.
  • If the composer.json file exists, all dependencies will be installed using the php composer.phar install command.

PHP with Swoole

  • Swoole is a tool that enhances performance of the standard PHP, allowing the webserver serve multiple requests asynchronously.
  • With this tools, you can create microservices, websockets, queue on background, etc. It allows you to execute events like in JavaScript.
  • It’s also important to mention that Swoole has compatibility with other PHP frameworks. A good example of a PHP framework is Laravel, which is compatible with Swoole thanks to the Octane.
  • You can use it instead of default PHP server by setting a custom START. Example:
npm run build && composer install --no-interaction --prefer-dist --optimize-autoloader && php artisan optimize && php artisan migrate --force && php -v && php artisan octane:start --host=0.0.0.0 --port=80 --workers=4 --task-workers=8 --server=swoole
  • You can check out all the powerful features of Swoole here

🖥️ Preparing Project for Upload

Before you can host your project on Square Cloud, ensure your project files are correctly configured for hosting. If your project includes a composer.json file, Square Cloud will automatically install dependencies using Composer. However, if your project also has Node dependencies (i.e., a package.json file), you should specify the installation process in the START field of your squarecloud.app file. For example:
START=npm install && php .....
The configuration (squarecloud.app/.config) file must be located in the root of the zip file. Otherwise, Square Cloud will not be able to find it during deployment.

📤 Uploading Project to Square Cloud

After preparing your project files, you can now upload them to Square Cloud and host your project.
  • Dashboard Upload
  • CLI Upload
Access the Square Cloud Dashboard and upload your project files.
If you continue facing technical difficulties, our specialized support team is available to assist you. Contact us and we'll be happy to help you resolve any issue.