William Jiang

JavaScript,PHP,Node,Perl,LAMP Web Developer – http://williamjxj.com; https://github.com/williamjxj?tab=repositories

Tag Archives: phpStorm

Vagrant in PhpStorm

Vagrant in PhpStorm – extend development environment

Vagrant(http://www.vagrantup.com/) is a very good PhpStorm add-on tool.
It creates and configures lightweight, reproducible, and portable development environments.

The following are the steps of how to use Vagrant in PhpStorm, extend the Windows-based PhpStorm development environment into a full-stack LAMP environment.

  1. Download 64-bit Vagrant for Windows. Install this .msi file (144MB) locally to C:Vagrant
  2. Then in PhpStorm: Ctrl+Shift+A -> Vagrant:
    – Vagrant executable: C:Vagrantbinvagrant.exe
    – Add Vagrant Box: lucid32

  3. in current PhpStorm project, Tools -> Vagrant -> Init in Project Root:
    generate a ‘Vagrantfile’ file.
  4. Modify the new generated Vagrantfile:
    config.vm.synced_folder "./", "/vagrant_mvc"

    This way share the whole project ‘/mvc/’ into the VM Linux machine

  5. Tools -> Vagrant -> Up
    (Re)boot the VM machine and mounting shared folders
  6. Tools -> Start SSH session …
    To ssh to this Linux Ubuntu lucid32 VM for details.
    – cd /vagrant_mvc
    — same file structures as within PhpStorm.
    — edit any file to immediately effected PhpStorm, coz the files are shared.

  7. To add LAMP tools into the VM, there is a good repository site: https://puphpet.com.
    https://puphpet.com has whole packages can be used into the VM machine:
    – VM OS (CentOS, Ubuntu, Debian
    – Server Packages
    – Webservers
    – Languages
    – Databases
    – etc
    By choose the defaults step by step to generate the Vagrant file and puphpet/ folder, copy them into PhpStorm’s current mvc/ directory,
    Reload the VM, all the LAMP-stack is download and installed. Very cool.
  8. This way creates a standard LAMP-full stack environment from the scratch to hold the whole project (here is ‘mvc’).
    Editable/Debugable by using PhpStorm, in the env of Linux (VM Server) as well as Windows.

using PhpStorm edit Remote PHP Project

using PhpStorm edit Remote PHP Project

I have a PhpStorm installed in local Windows, while having a remote CentOS 6.2 Server hoisted in godaddy.com.
How to edit ‘web apps reside in remote CentOS 6.2 Server’ within ‘local phpStorm env’?
Such as Laravel, Symfony2, cakePHP, worldpress project?
The following is the steps:

  1. Make sure a ftp server is running on centos 6.2, such as vsftpd. So local phpStorm can ftp access remote Linux server. In my CentOS 6.2:
    $ ps -e | grep ftp
    30261 ?        00:00:00 sftp-server

    mean the ftp server deamon is running.

  2. In PhpStorm IDE:
    File | New Project From Existing Files
    | Create New Project: Chooise Your Scenario
    | Web server is on remote host, files are accessible via FTP/SFTP/FTPS

  3. Make sure remote CentOS file directory’s permission is correctly: accessible, writable.
  4. Following the steps, config:
    – FTP Type. Here is SFTP (port 22)
    – remote file directory, e.g. /home/user/mvc/
    – remote web server root URL, e.g. http://example.com/
    – specify root folder on the remote server, e.g. /home/ussr/laravel/blog/
    – Specify project web path on remote server, e.g. http://example.com/laravel/blog/
    After done the config, it will auto sftp remote folder to locally PhpStorm Repository.
    Pretty cool!

  5. Now the new Prject can be editable in PhpStorm, using:
    Right click -> Upload to folder to sync the file.
  6. Also Menu -> Run to debug the updating. For debug, make sure XDEBUG is configured in both remote CentOS php.ini as well as local PhpStorm (Ctrl+Alt+S).
    So can debug remote web app in a local phpStorm environment.

  7. What else? It should work perfectly!

tips of using Jetbrains, xdebug and vim

The following are some summary using PhpStorm and vi.

1.vi: jump position

The following includes some strange symbols for vim, however useful:

Ctrl + o takes to previous location.
`. take you to the last change you made.
CTRL-O and CTRL-I seem to take you back and forth (Ctrl-o, Ctrl-i)

m[letter]
'[letter]
''
:marks

Redo / Undo
u: undo last change
Ctrl-R: Redo
U: return the last line which was modified to its original state

2. phpstorm

Excellent IDE: history, github integration, xdebug, code styles, ftp deployment, a lot of features which make development much easier.

// Always:
Ctrl + Shift + a

To navigate to a recently opened file: Ctrl+E
To navigate to a recently edited file:
Ctrl-Shift-E (recently opened file)
Ctrl-E (recently edited file)

Navigate a class, file or symbol with the specified name:
Class: Ctrl+N
File (directory): Ctrl+Shift+N
Symbol: Ctrl+Shift+Alt+N

To navigate to the next/previous change in the editor:
shortcuts: Ctrl+Shift+Alt+Down or Ctrl+Shift+Alt+Up.

Ctrl+b: open the function's source defination.
Ctrl+F12: show herited members.
Alt-click to close other files.

3. xdebug & phpStorm

By using XAMPP’s xdebug, and phpStorm, make drupal debug works in a web-application env.

To start Xdebug, you’ll need to append the XDEBUG_SESSION_START=xxx section to the url, i.e.:
http://localhost/drupal/index.php&XDEBUG_SESSION_START=random

It does not matter which browser you use, as long as the HTTP request is going to the apache/PHP server that has xdebug installed and configured.

Configuring XDebug with PHPStorm:

http://www.lullabot.com/blog/article/configuring-xdebug-osx-mountain-lion

4. Run node in webstorm

JetBrains’ Webstorm is fabulous. the ctrl+shift+a shortcut key is great, and git is pretty helpful.
Some useful shortcut keys:

PhpStorm Default Keymap – JetBrains

such as CTRL + SHIFT + F,
CTRL + R,
CTRL + ALT + I