Skip to main content

PHP

To use our example repositories, you must create a Sevalla account. This article includes examples of how to set up the following PHP applications to deploy on Sevalla’s Application Hosting services from a GitHub repository:

PHP

  1. In Sevalla, click Applications > Add application > select Git repository > Public repository, and complete as follows:
  2. Enter a Name, choose a Location, choose a pod size within Resources, and click Create & deploy.

During deployment, Sevalla automatically detects the Start command for the web process and installs dependencies defined in your composer.json file. The app is available as soon as the deployment finishes, and the Sevalla Welcome page loads at your application’s URL.

Prefer to watch the video version?

Web server setup

Sevalla automatically configures an Apache web server that serves your index.php file from the main directory of the project in the usual fashion. Create an index.php file in your project folder as your default index page.

Jigsaw

This is an example of how to set up a static site with Jigsaw on Sevalla’s Application Hosting services from a GitHub repository.

Jigsaw is a static site framework that uses Blade templates to create your page layouts and Markdown to build your content within the templates so you can produce simple static sites without complex coding knowledge. More information is available on the Jigsaw website.

  1. In Sevalla, click Applications > Add application > select Git repository > Public repository, and complete as follows:
  2. Enter a Name, choose a Location, choose a pod size within Resources, and click Create & deploy.

Jigsaw is based on Laravel; it’s a regular PHP-based application, so during deployment, Sevalla automatically detects the Start command for the web process and installs dependencies defined in your composer.json file. The app is available as soon as the deployment finishes, and a default Jigsaw page loads at your application’s URL.

Jigsaw default page after successful installation.

Jigsaw default page after successful installation.

Buildpacks

If you're using Buildpacks to build the application you’ll need to add these two Buildpacks:

  • Node JS
  • PHP

Web server setup

Start command

When you deploy the application, Sevalla automatically creates a web process with npm start as the Start command. If required, you can change this within Processes.

Leaf

This is an example of how to set up a Leaf PHP application to deploy on Sevalla’s Application Hosting services from a GitHub repository.

Leaf is a slim and lightweight PHP framework focused on developer experience, usability, and high-performance code. More information is available on the Leaf PHP website.

  1. In Sevalla, click Applications > Add application > select Git repository > Public repository, and complete as follows:
  2. Enter a Name, choose a Location, choose a pod size within Resources, and click Create & deploy.

During deployment, Sevalla automatically detects the Start command for the web process and installs dependencies defined in your composer.json file. The app is available as soon as the deployment finishes, and the Sevalla Welcome page loads at your application’s URL.

Prefer to watch the video version?

Web server setup

Port

Sevalla automatically sets the PORT environment variable. You should not define it yourself, and you should not hard-code it into the application.

Start command

When deploying the application, Sevalla automatically creates a web process running heroku-php-apache2.

Deployment lifecycle

Whenever a deployment is initiated (through creating an application or redeploying due to an incoming commit), the composer install command is run.

Statamic

This is an example of how to set up a Statamic application to deploy on Sevalla’s Application Hosting services from a GitHub repository.

Statamic is a flat-file CMS that, by default, stores all the data in the Git repository. Before you push the code to Sevalla, installing Statamic locally is the recommended approach for creating and maintaining your site. Next, create a super user account, and then commit and push all the changes to the repository.

  1. Statamic is based on Laravel, so the APP_KEY environment variable must be set. You can generate an app key yourself locally, or you can use this online Laravel key generator.
  2. In Sevalla, click Applications > Add application > select Git repository > Public repository, and complete as follows:
  3. Enter a Name, choose a Location, choose a pod size within Resources, and click Create.
  4. Once the application is created, click Environment variables > Add environment variable, and add the following:
    1. In Key 1, enter APP_KEY, and in Value 1, paste the key generated from Step 1.
    2. Click Add another, and in Key 2, enter APP_KINSTA, and in Value 2, enter true.
    3. Select Available during runtime and Available during build process.
  5. Click Deployments > Deploy now > Deploy application.

Statamic is based on Laravel; it’s a regular PHP-based application, so during deployment, Sevalla automatically detects the Start command for the web process and installs dependencies defined in your composer.json file. The app is available as soon as the deployment finishes, and the Statamic Welcome page loads at your application’s URL.

Prefer to watch the video version?

Environment variables

Statamic requires the following environment variables to be set:

Buildpacks

If you're using Buildpacks to build the application you’ll need to add these two Buildpacks:

  • Node.js
  • PHP

The buildpack that contains the primary language of your application must be the last one in the buildpacks list. In this example, PHP is the primary language and should be the last buildpack in the list.

Web server setup

Start command

The default web process is heroku-php-apache2 public/. If needed, you can change this command when adding your application (Set up your processes) or on the application’s Processes page after deployment.

PHP to send emails

This is an example of how to set up a PHP application to send emails via SendGrid on Sevalla’s Application Hosting services, deployed from a GitHub repository.

Sevalla does not natively support outbound emails from servers. Sending emails through specialized outbound providers such as SendGrid or Mailchimp offers more flexibility and higher success rates for transactional and campaign emails.

warning

While Sevalla doesn’t limit or control the outbound mail you send using a third-party SMTP service provider, we maintain a strict anti-spam policy. That policy covers emails sent via an application or site hosted at Sevalla, even if we are not the SMTP provider.

  1. In Sevalla, click Applications > Add application > select Git repository > Public repository, and complete as follows:
  2. Enter a Name, choose a Location, choose a pod size within Resources, and click Create.
  3. Once the application is created, click Environment variables > Add environment variable, and add the following:
    • SENDGRID_API_KEY: The API key from SendGrid.
    • TEST_EMAIL_TO_ADDRESS: The address to send the test email to.
    • TEST_EMAIL_FROM_ADDRESS: The address to send the test email from.
    • TEST_ENDPOINT: The endpoint to use as a trigger to send the test email. Please use a random string of at least 8 characters.
  4. Click Deployments > Deploy now > Deploy application.

The app is available as soon as the deployment finishes, and a Hello World page loads at your application’s URL.

PHP email sending Hello World page after successful installation.

PHP email sending Hello World page after successful installation.

Trigger an email

Through a very simple index.php entrypoint, two endpoints are exposed; all others will return a 404:

  • /: A simple page that returns the Hello World message
  • /${TEST_ENDPOINT}: A page that triggers a test email.

To trigger an email, find the URL of your deployment on the Deployments page, append your test endpoint to this URL, and visit the page. For example, if your TEST_ENDPOINT is set to o34nifnodhni4of and your latest deployment is at https://example.kinsta.app, you can trigger a test email from https://example.kinsta.app/o34nifnodhni4of in your browser.