Contribute, request a feature, or check out our resources
Join our community
Documentation
Blog
Report a bug
Request a feature
Contents
About
Getting started
Migrate
Learn
Contribute
We have just created a new multi-app project for you, based on API Platform component, API Platform Admin and Mercure.rocks server.
The generated code has been optimized for a typical web application hosted on Platform.sh.
- PHP 8.1
- PostgreSQL v13
- Composer-based build
- Yarn v1.22.15
- NodeJS v16
- a sample Product and Offer Entities
- Mercure server v0.14.4
The quickest way to deploy this template on Platform.sh is by clicking the button below.
This will automatically create a new project and initialize the repository for you.
Note:
Platform.sh templates prioritize upstream release versions over our own. Despite this, we update template dependencies on a scheduled basis independent of those upstreams.
Because of this, template repos do not contain releases. This may change in the future, but until then the-s dev
flag is necessary to usecomposer create-project
.
This section provides instructions for running the API Platform
template locally, connected to a local database instance.
In all cases for developing with Platform.sh, it's important to develop on an isolated environment - do not connect to data on your production environment when developing locally.
Each of the options below assume that you have already deployed this template to Platform.sh, as well as the following starting commands:
-
Install the Platform.sh CLI
Follow the instructions to install the Platform.sh CLI for your operating system. You can verify the installation by logging in (
platformsh login
) and listing your projects (platform project:list
). -
Find your
PROJECT_ID
by running the commandplatform project:list
+---------------+------------------------------------+------------------+---------------------------------+ | ID | Title | Region | Organization | +---------------+------------------------------------+------------------+---------------------------------+ | PROJECT_ID | Your Project Name | xx-3.platform.sh | your-username | +---------------+------------------------------------+------------------+---------------------------------+
-
Get your Platform.sh project
platform get PROJECT_ID cd project-name
-
Start the API component:
-
cd ./api
-
Install the Symfony CLI
-
start docker container for the database :
docker-compose up -d
-
symfony composer install
-
check that your
api/.env
file contains a validDATABASE_URL
to let Symfony connect to your databaseDATABASE_HOST=127.0.0.1 DATABASE_PORT=54968 DATABASE_NAME=api_platform DATABASE_USER=api_platform DATABASE_PASSWORD=api_platform DATABASE_URL="postgresql://${DATABASE_USER}:${DATABASE_PASSWORD}@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME}?serverVersion=14&charset=utf8"
-
symfony console doctrine:schema:create --dump-sql
-
symfony server:start -d
-
you can go on
https://localhost:8000/api
to display your swagger interface, showing entities Offer and Product CRUD option
Note: if symfony server does not start your app using default port 8000, please change
REACT_APP_PUBLIC_URL
from./admin/.env
file -
-
Start Mercure server locally in a new terminal tab
mercure % docker run \ -e MERCURE_PUBLISHER_JWT_KEY='!ChangeThisMercureHubJWTSecretKey!' \ -e MERCURE_SUBSCRIBER_JWT_KEY='!ChangeThisMercureHubJWTSecretKey!' \ -p 8006:80 \ -p 8007:443 \ dunglas/mercure caddy run --config /etc/caddy/Caddyfile.dev
-
Start the ADMIN component in a new terminal tab
-
cd ../admin
(assuming that you were in the./api
folder) -
yarn install
-
yarn start
-
a new browser tab open url http://localhost:3000
-
-
Create a new branch
platform branch new_branch
-
Develop your feature and commit it in GIT
-
Push your code to your environment
platform push
-
Push to production
platform checkout main platform merge new_branch
Note: For many of the steps above, you may need to include the CLI flags
-p PROJECT_ID
and-e ENVIRONMENT_ID
if you are not in the project directory or if the environment is associated with an existing pull request.
This repository has all the code it needs in order to deploy to Platform.sh.
Deploy directly to Platform.sh from the command line
-
Create a free trial:
Register for a 30 day free trial with Platform.sh. When you have completed signup, select the Create from scratch project option. Give you project a name, and select a region where you would like it to be deployed. As for the Production environment option, make sure to match it to this repository's settings, or to what you have updated the default branch to locally.
-
Install the Platform.sh CLI
Follow the instructions to install the Platform.sh CLI for your operating system. You can verify the installation by logging in (
platformsh login
) and listing your projects (platform project:list
). -
Set the project remote
Find your
PROJECT_ID
by running the commandplatform project:list
+---------------+------------------------------------+------------------+---------------------------------+ | ID | Title | Region | Organization | +---------------+------------------------------------+------------------+---------------------------------+ | PROJECT_ID | Your Project Name | xx-5.platform.sh | your-username | +---------------+------------------------------------+------------------+---------------------------------+
Then from within your local copy, run the command
platform project:set-remote PROJECT_ID
. -
Push using git
git push platform DEFAULT_BRANCH
-
or Push using platform CLI
platform push
Integrate with a GitHub repo and deploy pull requests
-
Create a free trial:
Register for a 30 day free trial with Platform.sh. When you have completed signup, select the Create from scratch project option. Give you project a name, and select a region where you would like it to be deployed. As for the Production environment option, make sure to match it to whatever you have set at
https://YOUR_NAMESPACE/nextjs-drupal
. -
Install the Platform.sh CLI
Follow the instructions to install the Platform.sh CLI for your operating system. You can verify the installation by logging in (
platformsh login
) and listing your projects (platform project:list
). -
Setup the integration:
Consult the GitHub integration documentation to finish connecting your repository to a project on Platform.sh. You will need to create an Access token on GitHub to do so.
-
Then, just use regular GIT commands to push your code to your repository. It will automatically update your corresponding Platform.sh environment
Integrate with a GitLab repo and deploy merge requests
-
Create a free trial:
Register for a 30 day free trial with Platform.sh. When you have completed signup, select the Create from scratch project option. Give you project a name, and select a region where you would like it to be deployed. As for the Production environment option, make sure to match it to this repository's settings, or to what you have updated the default branch to locally.
-
Install the Platform.sh CLI
Follow the instructions to install the Platform.sh CLI for your operating system. You can verify the installation by logging in (
platformsh login
) and listing your projects (platform project:list
). -
Create the repository
Create a new repository on GitLab, set it as a new remote for your local copy, and push to the default branch.
-
Setup the integration:
Consult the GitLab integration documentation to finish connecting a repository to a project on Platform.sh. You will need to create an Access token on GitLab to do so.
-
Then, just use regular GIT commands to push your code to your repository. It will automatically update your corresponding Platform.sh environment
Integrate with a Bitbucket repo and deploy pull requests
-
Create a free trial:
Register for a 30 day free trial with Platform.sh. When you have completed signup, select the Create from scratch project option. Give you project a name, and select a region where you would like it to be deployed. As for the Production environment option, make sure to match it to this repository's settings, or to what you have updated the default branch to locally.
-
Install the Platform.sh CLI
Follow the instructions to install the Platform.sh CLI for your operating system. You can verify the installation by logging in (platformsh login) and listing your projects (platform project:list).
-
Create the repository
Create a new repository on Bitbucket, set it as a new remote for your local copy, and push to the default branch.
-
Setup the integration:
Consult the Bitbucket integration documentation to finish connecting a repository to a project on Platform.sh. You will need to create an Access token on Bitbucket to do so.
-
Then, just use regular GIT commands to push your code to your repository. It will automatically update your corresponding Platform.sh environment
If you are moving an existing site to Platform.sh, then in addition to code you also need to migrate your data. That means your database and your files.
Importing the database
First, obtain a database dump from your current site and save your dump file as database.sql
. Then, import the database into your Platform.sh site using the CLI:
platform sql -e main < database.sql
Importing files
You first need to download your files from your current hosting environment. The easiest way is likely with rsync, but consult your old host's documentation.
The platform mount:upload
command provides a straightforward way to upload an entire directory to your site at once to a mount
defined in a .platform.app.yaml
file.
Under the hood, it uses an SSH tunnel and rsync, so it is as efficient as possible.
(There is also a platform mount:download
command you can use to download files later.)
Run the following from your local Git repository root (modifying the --source
path if needed and setting BRANCH_NAME
to the branch you are using).
A few examples are listed below, but repeat for all directories that contain data you would like to migrate.
platform mount:upload -e main --mount web/sites/default/files --source ./web/sites/default/files
platform mount:upload -e main --mount private --source ./private
Note that rsync
is picky about its trailing slashes, so be sure to include those.
With your application now deployed on Platform.sh, things get more interesting.
Run the command platform environment:branch new-feature
for your project, or open a trivial pull request off of your current branch.
The resulting environment is an exact copy of production (or corresponding parent environment). It contains identical infrastructure to what's been defined in your configuration files, and even includes data copied from your production environment in its services. On this isolated environment, you're free to make any changes to your application you need to, and really test how they will behave on production.
After that, here are a collection of additional resources you might find interesting as you continue with your migration to Platform.sh:
- Troubleshooting
- Adding a domain and going live
- (CDN) Content Delivery Networks
- Performance and observability with Blackfire.io
- Pricing
- Security and compliance
Accessing logs
After the environment has finished its deployment, you can investigate issues that occured on startup, deploy
and post_deploy
hooks, and generally at runtime using the CLI. Run the command:
platform ssh
If you are running the command outside of a local copy of the project, you will need to include the -p
(project) and/or -e
(environment) flags as well.
Once you have connected to the container, logs are available within /var/log/
for you to investigate.
Rebuilding cache
You may run into a database error after installing Symfony on your production environment initially.
To fix, SSH into the application container (platform ssh
) and rebuild the cache using Symfony console:
php bin/console cache:clear
php bin/console cache:pool:clear cache.app
This template includes a starting .blackfire.yml
file that can be used to enable Application Performance Monitoring, Profiling, Builds and Performance Testing on your project. Platform.sh comes with Blackfire pre-installed on application containers, and setting up requires minimal configuration.
- What is Blackfire?
- Configuring Blackfire.io on a Platform.sh project
- Blackfire.io Platform.sh documentation
- Profiling Cookbooks
- Monitoring Cookbooks
- Testing Cookbooks
- Using Builds
- Configuring Integrations
This template is maintained by the Platform.sh Developer Relations team, and they will be notified of all issues and pull requests you open here.
- Community: Share your question with the community, or see if it's already been asked on our Community site.
- Slack: If you haven't done so already, you can join Platform.sh's public Slack channels and ping the
@devrel_team
with any questions.
This template has been specifically designed to deploy on Platform.sh.
What is Platform.sh?
Platform.sh is a unified, secure, enterprise-grade platform for building, running and scaling web applications. We’re the leader in Fleet Ops: Everything you need to manage your fleet of websites and apps is available from the start. Because infrastructure and workflows are handled from the start, apps just work, so teams can focus on what really matters: making faster changes, collaborating confidently, and scaling responsibly. Whether managing a fleet of ten or ten thousand sites and apps, Platform.sh is the Developer- preferred solution that scales right.
Our key features include:
-
GitOps: Git as the source of truth
Every branch becomes a development environment, and nothing can change without a commit.
-
Batteries included: Managed infrastructure
Simple abstraction in YAML for committing and configuring infrastructure, fully managed patch updates, and 24 runtimes & services that can be added with a single line of code.
-
Instant cloning: Branch, merge, repeat
Reusable builds and automatically inherited production data provide true staging environments - experiment in isolation, test, then destroy or merge.
-
FleetOps: Fleet management platform
Leverage our public API along with custom tools like Source Operations and Activity Scripts to manage thousands of applications - their dependency updates, fresh content, and upstream code.
To find out more, check out the demo below and go to our website.
Every one of our templates is open source, and they're important resources for users trying to deploy to Platform.sh for the first time or better understand the platform. They act as getting started guides, but also contain a number of helpful tips and best practices when working with certain languages and frameworks.
See something that's wrong with this template that needs to be fixed? Something in the documentation unclear or missing? Let us know!
How to contribute
Report a bug
Submit a feature request
Open a pull request
Need help?
Ask the Platform.sh Community
Join us on Slack
Made with contrib.rocks