---
# System prepended metadata

title: PHPStorm Setup

---

# PHPStorm Setup

[TOC]

Requires a finished vagrant setup.



## Setup inside Vagrant Box

### Composer Update

SSH into your vagrant box (`vagrant ssh`) Run `composer update` in the root directory of the project (probably `/var/www/zeldachronicles`)


### Remote Debugger

edit `/etc/php/7.0/mods-available/xdebug.ini`. Make sure your file looks similar to this:

```
zend_extension=xdebug.so

xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_host=192.168.33.1
xdebug.remote_connect_back=1
xdebug.remote_mode=req
xdebug.idekey=PHPSTORM
xdebug.profiler_output_dir=/var/www/zeldachronicles/xdebug
xdebug.profiler_enable = 0
```

## PHPStorm Settings

In PHPStorm open the Settings-Menu (`CTRL+ALT+S`). 

### Directories

under `Directories` mark the directories as follows:



| Directory                 | Type    | Package Prefix |
| ------------------------- | ------- | -------------- |
| source/lib                | Sources | wbb            |
| source/wcf/lib            | Sources | wcf            |
| source/wcf/lib/ezelo/test | Tests   | -              |


### SSH Configuration

Under `Tools > SSH Configurations` add a new SSH Configuration for your vagrant box

| Field               | Value                                                                             |
| ------------------- | --------------------------------------------------------------------------------- |
| Host                | zeldachronicles.local                                                             |
| Port                | 22                                                                                |
| Username            | vagrant                                                                           |
| Authentication type | Key Pair                                                                          |
| Private key file    | <ProjectDir>/scripts/zcrun/vagrant/.vagrant/machines/zcrun/virtualbox/private_key |

`Test Connection` should work now.


### PHP 

#### Setup Remote PHP Interpreter

Under `Languages & Frameworks > PHP` Set `PHP Language Level` to `7.0`. Also: Add a new Remote CLI Interpreter via SSH on the previously created SSH Configuration. Leave everything as default.

#### Setup Remote Server

Under `Languages & Frameworks > PHP > Servers` add a new Server. Call it `zeldachronicles.local`.

| Field             | Value                 |
| ----------------- | --------------------- |
| Host              | zeldachronicles.local |
| Port              | 80                    |
| Use Path mappings | yes                   |

Now map the project root to `/var/www/zeldachronicles`.

### Setup Remote Test Frameworks

In the Settings under `Languages & Frameworks > PHP > Test Frameworks`. Delete the local interpreters.

#### PHPSpec
Add a `PHPSpec by Remote Interpreter` Framework. Choose your remote interpreter from the dropdown.

| Field                      | Value                                                                 |
| -------------------------- | --------------------------------------------------------------------- |
| Path to PHPSpec executable | `/var/www/zeldachronicles/vendor/phpspec/phpspec/bin/phpspec`         |
| default configuration file | `/var/www/zeldachronicles/phpspec.docker.yml`                         |
| Path Mappings              | Local Path: `<Project root>`; Remote Path: `/var/www/zeldachronicles` |

#### PHPUnit

### Setup Test Run Configurations
Add a `PHPUnit by Remote Interpreter` Framework. Choose your remote interpreter from the dropdown. 

| Field                      | Value                                                                |
| -------------------------- | -------------------------------------------------------------------- |
| Path to PHPUnit.phar       | `/var/www/zeldachronicles/vendor/phpunit/phpunit/phpunit`            |
| default configuration file | `/var/www/zeldachronicles/phpunit.xml`                               |
| Path Mappings              | Local Path: `<Project root>`; Remote Path: `/var/www/zeldachronicles` |

Close the Settings. Now go to `Run > Edit Configurations...` 

#### Setup PHPSpec

Add a new PHPSpec Configuration. Call it `Tests (PHPSpec)`.

| Field       | Value                         |
| ----------- | ----------------------------- |
| Test Scope  | Defined in Configuration File |
| Interpreter | <Your remote interpreter>     |

Running the configuration should work.


#### Setup PHPUnit
Add a new PHPUnit Configuration. Call it `Tests (PHPUnit)`.

| Field       | Value                         |
| ----------- | ----------------------------- |
| Test Scope  | Defined in Configuration File |
| Interpreter | <Your remote interpreter>     |

### Test that Everything works
todo