Skip to content

CleverCloud/php-composer-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP Composer Example Application on Clever Cloud

Clever Cloud - PaaS

This is a minimal PHP application that demonstrates how to use Composer for dependency management on Clever Cloud.

About the Application

This application provides a simple PHP page that displays PHP configuration info.

  • index.php - Main page displaying PHP info
  • composer.json - Composer configuration with dependencies

Technology Stack

  • PHP 8.5 - Server-side scripting language
  • Composer - Dependency manager for PHP

Prerequisites

  • PHP 8.5+
  • Composer

Running the Application Locally

composer install
php -S localhost:8080

The application will be accessible at http://localhost:8080.

Deploying on Clever Cloud

You have two options to deploy your PHP application on Clever Cloud: using the Web Console or using the Clever Tools CLI.

Option 1: Deploy using the Web Console

1. Create an account on Clever Cloud

If you don't already have an account, go to the Clever Cloud console and follow the registration instructions.

2. Set up your application on Clever Cloud

  1. Log in to the Clever Cloud console
  2. Click on "Create" and select "An application"
  3. Choose "PHP" as the runtime environment
  4. Configure your application settings (name, region, etc.)

3. Configure Environment Variables

Add the following environment variables in the Clever Cloud console:

Variable Value Description
CC_PHP_VERSION 8 PHP version to use

Note: Composer dependencies are installed automatically during the build phase when a composer.json file is present at the root of the repository. No additional configuration is needed.

4. Deploy Your Application

You can deploy your application using Git:

# Add Clever Cloud as a remote repository
git remote add clever git+ssh://git@push-par-clevercloud-customers.services.clever-cloud.com/app_<your-app-id>.git

# Push your code to deploy
git push clever master

Option 2: Deploy using Clever Tools CLI

1. Install Clever Tools

Install the Clever Tools CLI following the official documentation:

# Using npm
npm install -g clever-tools

# Or using Homebrew (macOS)
brew install clever-tools

2. Log in to your Clever Cloud account

clever login

3. Create a new application

# Step 1: Initialize the current directory as a Clever Cloud application
clever create --type php <YOUR_APP_NAME>

# Step 2: Add your domain (optional but recommended)
clever domain add <YOUR_DOMAIN_NAME>

# Step 3: Set the required environment variables
clever env set CC_PHP_VERSION 8.5

4. Deploy your application

clever deploy

5. Open your application in a browser

Once deployed, you can access your application at https://<YOUR_DOMAIN_NAME>/.

Composer on Clever Cloud

Composer is supported out of the box. If a composer.json file is present at the root of your repository, dependencies are installed automatically during the build phase. For more details, see the Composer on Clever Cloud documentation.

Monitoring Your Application

Once deployed, you can monitor your application through:

  • Web Console: The Clever Cloud console provides logs, metrics, and other tools to help you manage your application.
  • CLI: Use clever logs to view application logs and clever status to check the status of your application.

Additional Resources

About

Run PHP with Composer on Clever Cloud

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages