|
| 1 | +# Vapor |
| 2 | + |
| 3 | +- [Introduction](#introduction) |
| 4 | +- [Connect to Serverless Server](#connect-to-serverless-server) |
| 5 | +- [Select Connection](#select-connection) |
| 6 | +- [Run Code](#run-code) |
| 7 | +- [How it works?](#how-it-works) |
| 8 | + |
| 9 | +## Introduction |
| 10 | + |
| 11 | +TweakPHP supports running PHP code directly inside a Laravel Vapor environment with vapor tinker cli. This allows you to test and execute code within the same context as your deployed serverless infrastructure. |
| 12 | + |
| 13 | +::: danger |
| 14 | +There are no safety checks or restrictions in place. |
| 15 | +**If you select a production environment, the code will be executed directly in that environment.** |
| 16 | +Use this feature with caution and verify the selected environment before running any code. |
| 17 | +::: |
| 18 | + |
| 19 | +## Connect to Serverless Server |
| 20 | + |
| 21 | +To connect to a Vapor environment, make sure your project contains a valid vapor.yml file at its root. TweakPHP will automatically detect environments from vapor file. |
| 22 | + |
| 23 | +## Select Connection |
| 24 | + |
| 25 | +Once a vapor.yml file is detected, TweakPHP automatically extracts the available environments and displays them in the environment selection dropdown. The Vapor CLI is used behind the scenes to establish the connection. |
| 26 | + |
| 27 | +## Run Code |
| 28 | + |
| 29 | +Select the desired environment, write your PHP code in the editor without including `<?php` or `?>` tags — TweakPHP will handle them automatically if they are present. Once ready, click Run or hit `Command+R` on mac or `Ctrl+R` to execute the code inside the selected Vapor environment. The output will be streamed back to the interface. |
| 30 | + |
| 31 | +::: info |
| 32 | +Stack trace visualization is disabled when running in Vapor environments and the use of custom loaders is not supported. |
| 33 | +::: |
| 34 | + |
| 35 | +## How it works? |
| 36 | + |
| 37 | +TweakPHP leverages the Vapor CLI to run your code inside a selected environment: |
| 38 | +1. Reads available environments from the vapor.yml file. |
| 39 | +2. Allows the user to select an environment via the interface. |
| 40 | +3. Submits the code using a CLI command (vapor tinker cli). |
| 41 | +4. Captures and returns the output to the interface. |
| 42 | + |
| 43 | +This approach ensures your code is executed in the same environment as your deployed application, including its runtime, services, and configuration. |
0 commit comments