craftcms/cloud

There is no license information available for the latest version (2.6.8) of this package.

Installs: 4 016

Dependents: 5

Suggesters: 0

Security: 0

Stars: 0

Watchers: 3

Forks: 2

Open Issues: 8

Type:yii2-extension

2.6.8 2024-12-05 15:47 UTC

This package is auto-updated.

Last update: 2024-12-22 17:12:01 UTC


README

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 extension deep-dive, in the knowledge base.

Installation

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

Tip

This process includes the creation of a craft-cloud.yaml configuration file which helps Cloud understand your project’s structure and determines which versions of PHP and Node your project will use during builds and at runtime.

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

cloud.artifactUrl()

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

{# Output a script tag with a build-specific URL: #}
<script src="{{ cloud.artifactUrl('dist/js/app.js') }}"></script>

{# You can also use the extension-provided alias: #}
{% js '@artifactBaseUrl/dist/js/app.js' %}

Read more about how to use artifact URLs.

cloud.isCraftCloud

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

{% if cloud.isCraftCloud %}
  Welcome to Cloud!
{% endif %}

Aliases

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

@web

On Cloud, the @web alias is guaranteed to be the correct environment URL for each HTTP context, whether that be a preview domain or custom domain.

@artifactBaseUrl

Equivalent to cloud.artifactUrl(), this allows Project Config settings to take advantage of dynamic, build-specific 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.

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