Skip to content

Latest commit

 

History

History

laravel

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

PHP + Laravel + Tinker

This examples demonstrate how to setup a runops agent in a standalone VM allowing to run commands inside a laravel project using Artisan Tinker REPL

Apps

Requirements

  • Vagrant
  • runops cli
  • A user with permission to create targets and tasks in an organization on runops.
  • An agent token with permission to run tasks

Setup & Run

  1. Open an terminal and execute the steps below
git clone https://github.com/runopsio/example-apps.git && cd example-apps/laravel
vagrant up
vagrant ssh
sudo su -
# /opt/start-agent.sh <agent-token> <tag> </path/to/laravel/project/artisan>
/opt/start-agent.sh mytoken dev /opt/example-app/artisan

It's possible to map several laravel projects in the same agent.

  1. Open another terminal, create a target and execute a command in REPL
runops targets create --name example-app-repl --type bash --secret_provider env-var --secret_path APP_CONFIG --tags local
runops tasks create -t example-app-repl -s 'array_slice(getenv(), 0, 5)'
=> [
     "PWD" => "/root",
     "HOME" => "/home/runops",
     "SHLVL" => "0",
     "PHP_APP" => "/opt/example-app/artisan",
     "PATH" => "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin",
   ]

This example uses a feature called Custom Commands on targets which aren't general available yet, after creating a target, a runops member needs to configure manually the command which will be executed in the agent, in this example is php [[PHP_APP]] tinker -n

  1. [Optional] Use the runops REPL instead
runops tasks repl
REPL started, each command will be executed remotely
and displayed in this session. https://runops.io/docs/user-guides/REPL
Type :help to list available commands

=> :target example-app-repl
example-app-repl=>
#_=> function helloWorldMsg() {
#_=>   print "Hello World from Runops!\n";
#_=> }
#_=> helloWorldMsg();
#_=>
Hello World from Runops!
=> null