Skip to content

craftcms/cloud-extension-yii2

 
 

Repository files navigation

Craft Cloud icon

Craft Cloud Extension

Welcome to Craft Cloud!

This repository contains source code for the craftcms/cloud Composer package, which is required to run a Craft project on our first-party hosting platform, Craft Cloud.

When installed, the extension automatically bootstraps itself and makes necessary application configuration changes for the detected environment:

  • 🌩️ Cloud: There’s no infrastructure settings to worry about—database, queue, cache, and session configuration is handled for you.
  • đź’» Local development: Craft runs normally, in your favorite development environment.

✨ To learn more about Cloud, check out our website—or dive right in with Craft Console. Interested in everything the extension does to get your app ready for Cloud? Read our Cloud module deep-dive, in the knowledge base.

Installation

The Cloud module can be installed in any existing Craft 4.5+ project by running php craft setup/cloud. Craft will install the craftcms/cloud package and run the module’s own setup wizard.

When you deploy a project to Cloud, the cloud/up command will run, wrapping Craft’s built-in up command and adding the cache and session tables (if they’re not already present).

Filesystem

When setting up your project’s assets, use the provided Craft Cloud filesystem type. Read more about managing assets in Cloud projects.

Developer Features

Template Helpers

The extension provides two new Twig functions and one global variable:

artifactUrl()

Generates a URL to a resource that was uploaded to the CDN during the build and deployment process.

isCraftCloud

true when the app detects it is running on Cloud infrastructure, false otherwise.

Aliases

The following aliases are available, in addition to those provided by Craft.

@web

We override the @web alias to guarantee that the correct environment URL is used in all HTTP contexts.

@artifactBaseUrl

Equivalent to artifactsUrl(), this allows Project Config settings to take advantage of dynamically-determined CDN URLs.

Configuration

Most configuration (to Craft and the extension itself) is handled directly by Cloud infrastructure, through environment overrides. These options are provided strictly for reference, and have limited utility outside the platform.

Option Type Description
accessKey string AWS access key, used for communicating with storage APIs.
accessSecret string AWS access secret, used in conjunction with the accessKey.
cdnBaseUrl string Used when building URLs to assets and other build artifacts.
cdnSigningKey string A secret value used to protect transform URLs against abuse.
useAssetCdn boolean Whether or not to enable the CDN for uploaded assets.
useArtifactCdn boolean Whether or not to enable the CDN for build artifacts and asset bundles.
environmentId string UUID of the current environment.
projectId string UUID of the current project.
region string The app region, chosen when creating the project.
s3ClientOptions array Additional settings to pass to the Aws\S3\S3Client instance when accessing storage APIs.
sqsUrl string Determines how Craft communicates with the underlying queue provider.

These options can also be set via environment overrides beginning with CRAFT_CLOUD_.