Guides
Laravel PHP application

Getting an application running on Wasmer Edge is essentially working out how to package it as a deployable image. Once packaged, it can be deployed to the Wasmer Edge (opens in a new tab) platform.

In this guide we'll learn how to deploy a Laravel application on Wasmer Edge. You can also set up a new app easily with the Laravel template for Wasmer Edge (opens in a new tab).

Prepare a Laravel app

Bring your own Laravel app, or create a new one!

If you want to start fresh, here's how to set up a new application. You'll need PHP 8+ and composer installed locally. You can check your PHP version using php --version.

$ composer create-project laravel/laravel wasmer-edge-laravel
$ cd wasmer-edge-laravel
$ php artisan serve

You should be able to visit http://localhost:8000 (opens in a new tab) and see the home page.

Deploy to Wasmer Edge

Install Wasmer

Click here for instructions on how to install Wasmer if you haven't done it already!

Setup a Wasmer Package

Now, lets make your app run with Wasmer. For that, you'll need to create a wasmer.toml file. You can simply use this configuration:

wasmer.toml
[dependencies]
"php/php" = "=8.3.4"
 
[fs]
"/app/" = "."
 
[[command]]
name = "run"
module = "php/php:php"
runner = "wasi"
[command.annotations.wasi]
main-args = ["-t", "/app/public", "-S", "localhost:8080"]

You can test that the app works properly with Wasmer by running in your shell:

$ wasmer run .

And then visiting http://localhost:8080/ (opens in a new tab)

Once you verify that everything is running well, you should be ready to deploy to Wasmer Edge!

Custom PHP settings

Please check Wasmer PHP guide if you want to customize PHP settings for your app.

Deploy

Now, simply run wasmer deploy and that will guide you to depoloying the app.

In case you have any secrets or environment variables you want to set up, you can set secrets with the wasmer app secrets command:

wasmer app secrets create SOME_SECRET_KEY SOME_VALUE

Conclusion

Congratulations! You have successfully deployed your PHP Laravel application on Wasmer Edge 🚀.

Tip: To make redeploy, simply run wasmer deploy again to deploy the changes.

Resources

wasmer-examples/laravel-wasmer-starter