Skip to content

Instantly share code, notes, and snippets.

@lokal-profil
Last active June 24, 2020 20:41
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lokal-profil/eab463ba21ffe620e20548e068c32e91 to your computer and use it in GitHub Desktop.
Save lokal-profil/eab463ba21ffe620e20548e068c32e91 to your computer and use it in GitHub Desktop.
Instructions for setting up phan on Vagrant

Install php-ast

Phan needs php-ast to run, unfortunately this does not come included in the MediaWiki-Vagrant installation. To install it follow these instructions (largely influenced by Mainframe98). You can also try to run the associated shell script to automate this part.

From the vagrant home directory run vagrant up to spin up vagrant then run vagrant ssh to enter your vagrant shell.

Inside Vagrant

Run the following and accept any prompts

wget http://pear.php.net/go-pear.phar
php go-pear.phar
sudo pear/bin/pecl install ast

Then create /etc/php/7.2/cli/conf.d/15-ast.ini with the following content

; configuration for php ast module
; priority=15
extension=ast.so

Exit the vagrant shell (exit)

Up the memory of Vagrant

Create Vagrantfile-extra.rb with the following content

Vagrant.configure('2') do |config|
      config.vm.provider :virtualbox do |vb|
          # See http://www.virtualbox.org/manual/ch08.html for additional options.
          vb.customize ['modifyvm', :id, '--memory', '3072']
      end
end

To run phan

Replace Wikispeech by the name of your MediaWiki extension as needed.

Before running phan for the first time make sure you run composer update from the /vagrant/mediawiki/extensions/Wikispeech directory.

To run phan (from within the vagrant shell) execute the following command

/vagrant/mediawiki/extensions/Wikispeech/vendor/bin/phan -d /vagrant/mediawiki/extensions/Wikispeech/ -p
#! /usr/bin/env bash
# Run from your vagrant directory after having called ´vagrant up`
vagrant ssh <<'ENDSSH'
echo 'download pear'
wget http://pear.php.net/go-pear.phar
# install pear answering any prompts
echo 'install pear'
php go-pear.phar <<'EOF'
n
EOF
echo 'install ast'
sudo pear/bin/pecl install ast
# add ast to php.ini
echo 'add ast to php.ini'
sudo tee -a /etc/php/7.2/cli/conf.d/15-ast.ini > /dev/null << EOF
; configuration for php ast module
; priority=15
extension=ast.so
EOF
ENDSSH
echo 'create Vagrantfile-extra.rb'
cat <<EOT >> Vagrantfile-extra.rb
Vagrant.configure('2') do |config|
config.vm.provider :virtualbox do |vb|
# See http://www.virtualbox.org/manual/ch08.html for additional options.
vb.customize ['modifyvm', :id, '--memory', '3072']
end
end
EOT
@sebastian-berlin-wmse
Copy link

I think there's a link missing to be able to run /vagrant/mediawiki/extensions/Wikispeech/vendor/bin/phan.

@lokal-profil
Copy link
Author

I think there's a link missing to be able to run /vagrant/mediawiki/extensions/Wikispeech/vendor/bin/phan.

Added a note about composer update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment