Skip to content

[Laravel] Resubmit: Adding the "Getting started" guide for Laravel #3899

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sites/upsun/config/_default/params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ vendor:
services: .upsun/config.yaml
app: .upsun/config.yaml
apps: .upsun/config.yaml
env: .environment
prefix:
apps: applications
services: services
Expand Down
43 changes: 0 additions & 43 deletions sites/upsun/src/get-started/stacks/laravel.md

This file was deleted.

48 changes: 48 additions & 0 deletions sites/upsun/src/get-started/stacks/laravel/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
title: Deploying Laravel on Upsun
sidebarTitle: Laravel
sectionBefore: PHP
layout: single
weight: -65
description: |
Complete the last required steps to successfully deploy Laravel on {{% vendor/name %}}.
---

{{< note theme="info" >}}

Before you start, check out the [{{% vendor/name %}} demo app](https://console.upsun.com/projects/create-project) and the main [Getting started guide](/get-started/here/_index.md).
They provide all of the core concepts and common commands you need to know before using the materials below.

{{< /note >}}

{{< get-started/steps >}}

## Further resources

### Documentation

- [PHP documentation](/languages/php/)

- [Extensions](/languages/php/extensions)

- [Performance tuning](/languages/php/tuning)

- [PHP-FPM sizing](/languages/php/fpm)

- [Swoole on {{% vendor/name %}}](/languages/php/swoole)

- [Authenticated Composer](/languages/php/composer-auth)

### Community content

- [Laravel topics](https://support.platform.sh/hc/en-us/search?utf8=%E2%9C%93&query=laravel)

- [PHP topics](https://support.platform.sh/hc/en-us/search?utf8=%E2%9C%93&query=php)

### Blogs

- [_Upsun: the missing PaaS to scale Laravel applications_](https://upsun.com/blog/paas-to-scale-laravel-apps/)

<!-- ## Video -->

{{< guide-buttons next="Get started" nextLink="/get-started/stacks/laravel/get-started.md" type="*" >}}
23 changes: 23 additions & 0 deletions sites/upsun/src/get-started/stacks/laravel/blackfire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
title: "Continous Observability with Blackfire"
sidebarTitle: "Blackfire"
weight: -90
description: Set up a continuous observability strategy for your Laravel app with Blackfire.
---

[Blackfire.io](/increase-observability/application-metrics/blackfire.md) is the recommended solution
for monitoring and profiling web sites and apps.
Blackfire works seamlessly with any app built with Laravel.

Blackfire PHP SDK provides the following [integrations with
Laravel](https://docs.blackfire.io/php/integrations/laravel/index):

- [Laravel Artisan](https://docs.blackfire.io/php/integrations/laravel/artisan)
- [Laravel Horizon and queue services](https://docs.blackfire.io/php/integrations/laravel/horizon)
- [Laravel Tests](https://docs.blackfire.io/php/integrations/laravel/tests)
- [Laravel Octane](https://docs.blackfire.io/php/integrations/laravel/octane)

Please refer to the [Blackfire documentation](https://docs.blackfire.io/testing-cookbooks/tests#the-code-blackfire-yaml-code-file) to set up a `.blackfire.yml` configuration to enable custom [performance tests](https://docs.blackfire.io/testing-cookbooks/index)
and automated [builds](https://docs.blackfire.io/builds-cookbooks/index).

{{< guide-buttons previous="Back" next="Debug with Telescope" nextLink="/get-started/stacks/laravel/laravel-telescope.md" type="*" >}}
76 changes: 76 additions & 0 deletions sites/upsun/src/get-started/stacks/laravel/crons.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
title: "Set up cron jobs"
weight: -105
description: |
Understand how to configure Laravel cron jobs.
---

Cron jobs allow you to run scheduled tasks at specified times or intervals.

While you can run your own custom tasks, Laravel provides a scheduler to simplify the implementation.
To implement it, see the Laravel [Task Scheduling documentation](https://laravel.com/docs/master/scheduling).

## Set up a cron job

To set up a cron job, update your {{% vendor/name %}} configuration as follows:

```yaml {configFile="app"}
applications:
myapp:
[...]
crons:
snapshot:
spec: * * * * *
cmd: |
php artisan schedule:run >> /dev/null 2>&1
```

## Run cron jobs based on environment type

To run a command in a cron hook for specific environment types,
use the `PLATFORM_ENVIRONMENT_TYPE` environment variable:

```yaml {configFile="app"}
applications:
myapp:
[...]
crons:
snapshot:
spec: 0 5 * * *
cmd: |
# only run for the production environment, aka main branch
if [ "$PLATFORM_ENVIRONMENT_TYPE" = "production" ]; then
php artisan schedule:run >> /dev/null 2>&1
fi
```

## Run the Laravel scheduler every minute

Cron job execution on the default {{< vendor/name >}} offering are limited to once every 5 minutes.
For more information, see the [documentation on crons](/create-apps/app-reference.html#crons).

However, you can add a [worker](/create-apps/app-reference#workers)
and specify a start command that [runs the scheduler every minute](https://laravel.com/docs/11.x/scheduling#running-the-scheduler-locally).
To do so, use the following configuration:

```yaml {configFile="app"}
applications:
[...]
{{< variable "APP_NAME" >}}:
[...]
workers:
scheduler:
commands:
start: |
php artisan schedule:work
```

{{< note title="Warning" theme="warning" >}}

Web and worker containers don't share mount targets.
You can't share files between those containers using the filesystem.
To share data between containers, use [services](/add-services/_index.md).

{{< /note >}}

{{< guide-buttons previous="Back" next="Manage observability with Blackfire" nextLink="/get-started/stacks/laravel/blackfire.md" type="*" >}}
Loading
Loading