Revision #21 has been created by rackycz on Feb 12, 2021, 1:36:53 AM with the memo:
Vagrant
« previous (#20) next (#22) »
Changes
Title
unchanged
Yii v2 snippet guide III
Category
unchanged
Tutorials
Yii version
unchanged
2.0
Tags
unchanged
tutorial,yii2,beginer
Content
changed
[...]
Vagrant creates a virtual machine with a web server (using almost any OS/PHP/SQL you specify), while the docroot is on your local disk so you can easily modify the PHP files in your IDE and in your OS. Vagrant works just like composer or NPM. It is a library of available OS images and you just pick one. Whole configuration is defined in one text-file, named Vagrantfile, and all you need is just a few commands to run it. And debugging is no problem.
List of all available OS images is here:
- https://app.vagrantup.com/boxes/search
Both Yii demo-applications already contain the Vagrantfile, but its setup is unclear to me - it is too PRO. So I want to publish my simplififed version which uses OS image named ([scotch/box
)[](https://box.scotch.io
]). (It has some advantages, the disadvantage is older PHP in the free version)
The Vagrantfile is stored in the root-folder of your demo-project. My Vagrantfile contains following commands.[...]
Before you use Vagrantfile, you must install Vagrant and VirtualBox (Sadly, these days VirtualBox does not work on the ARM-based Macs with the M1 chip):
- Install ([Virtual Box
)[](https://www.virtualbox.org/wiki/Downloads
]), I recommend to install also the "Extension Pack", but is might be done automatically by "scotch/box".
- Install
([Vagrant
)[](https://www.vagrantup.com/downloads
]) ... on Windows restart is needed :-(
- https://www.sitepoint.com/re-introducing-vagrant-right-way-start-php/[...]
- "vagrant -v" should show you the version if things work.
- "vagrant init" creates a new project (You won't need it now)
- "vagrant up" creates the environment (this runs the Vagrantfile and creates/starts the virtual
)
Once virtual is running, you can call also these:
- "vagrant ssh" opens Linux shell
if the virtual machine is already running.
- "vagrant halt" stops the virtual
- "vagrant reload" restarts the virtual and does NOT run config.vm.provision[...]
- Current IP: hostname -I
In "scotch/box" I do not use PhpMyAdmin , but ([Adminer
)[](https://www.adminer.org/en
/]). It is one simple PHP script and it will run without any installations.
Just copy the adminer.php script to your docroot and access it via browser. Use the same login as in configurafion of Yii. Server will be localhost.