Skip to content
This repository was archived by the owner on Feb 8, 2024. It is now read-only.

4.1. Setups

Shinichi Okada edited this page May 6, 2015 · 6 revisions

Shortcuts

Some shortcuts.

cmd + , //to go to preference.
cmd + p // to open a file. The default was shift + cmd + o. I remapped this. 
cmd + r // File structure. The default was  mapped to cmd + F12
cmd + option + o // to find symbol/method
cmd + up  then enter// to open a navigation bar
cmd + 1 // to toggle sidebar
cmd + o // Navigate class
shift + cmd + a // search everything
option + up (repeat option + up) // select word, line, method, class, etc
cmd + click a method name // jump to the method
cmd + C // to copy a line without selecting a line
cmd + X // to delete a line without selecting a line
cmd + V // to paste a line

Minimum views

Turn of View>Status bar, Tool Buttons, Navigation bar and Toolbar. Go to the preferences, cmd + ,. And search breadcrumb and deselect Show HTML breadcrumbs and other bread crumbs. Restart PhpStorm.

In preference, Editor>Colors & Fonts to change a scheme name. Font to change a size and line spacing.

Adding Color Scheme

  1. Go to http://daylerees.github.io/ and see which scheme you like.
  2. Go to https://github.com/daylerees/colour-schemes and click jetbrain and select the same scheme you like. And click Raw and copy the URL.
  3. In your terminal cd ~/Library/Preferences/WebIde80/colors. WebIde80 could be different. It depends on app.
  4. curl -O paste-your-url-here OR if you have wget wget paste-your-url-here. If it doesn't work, then just create a file of the colorscheme. -O will create a file. And it must be Raw file.
  5. Restart your Phpstorm/pycharm and cmd+, to select the new theme.

Removing Tabs

Right click (or cmt+, and search tab) on a tab to select Tabs placement and click None.

To match sidebar to the main screen color

shift+cmd+a to bring up a search. Search plugins and click config plugins. Click Browse repositories at the bottom. And search color Ide. Install it and restart.

To change keymap

shift+cmd+a to search keymap and select Activate Keymap. Create a copy and name it. Search a keyboard shortcut by clicking an icon next to trash. Remove it and then add a new keyboard shortcut. If a new shortcut exists, then a pop-up will come to remove other assignment. Click Apply and save it.

Create a new file

cmd+up to jump to navigation bar (floating folder), click enter and then type app to go to the folder app and enter. cmd+n to pop-up a new and select Php class, Php file, a file or folder.

Customize a file

shift+cmd+a which search action or option name or shift+shift which search everywhere. Type file template and go to File and Code Templates in Preferences. In templates>PHPclass, it includes PHP File Header.php. Go to Includes tab and modify PHP FIle Header.

Add a new Template, Name: Eloquent Model, Extension: php. Copy and paste from PHP Class.

<?php

#if (${NAMESPACE})
namespace ${NAMESPACE};
#end

class ${NAME} extends Eloquent{
    
    protected \$fillable = [];

}

Test it to create a file under app/models/ with File name: Order, NAMESPACE: Acme.

Live templates - Snippets

cmd+E shows all recent files.

Create a textfield template.

<!--$VALUE$ Form Input -->
<div class="form-group">
    {{ Form::label('$NAME$', '$VALUE$:') }}
    {{ Form::text('$NAME$', 'null', ['class'=>'form-control']) }}
</div>    

Copy the above and shift shift to search live template and click Save as Live template. Type Abbreviation: textfield, Description: Form text field under user section which automatically selected in this case. You may need to change Applicable in ... for file types. Click Edit varialbes, for VALUE, expression select capitalize(NAME). And change the order if necessary. In this case I want NAME to be the first, so that after expansion, it will highlight to add NAME variable.

Now type textfield to expand it.

In preference Live Templates, click + to add Abbreviation: passwordfield, Description: Form password field.

<!--$VALUE$ Form Input -->
<div class="form-group">
    {{ Form::label('$NAME$', '$VALUE$:') }}
    {{ Form::password('$NAME$', ['class'=>'form-control']) }}
</div>    

And Edit variables. VALUE Expression to capitalize(NAME). And change Applicable to HTML and PHP.

Custom formatting

option + cmd + L or shift shift and Reformat code and Run to reformat. To customize formatting, go to preferences > Code Style > PHP. In Wrapping and Braces > Braces placement,

In class declaration: End of line 
In function declaration: Next line
Other: Next line

For Blank Lines,

After class header: 1

Other

Tick Align key-value pairs
Tick Convert True/False constants to Lower case
Tick Convert Null constant to: Lower case
Tick Blank line before return statement
Tick Spaces around variable/expression in brackets

Spaces

Enable Around Operators>Unary operators
Enable Other>After type cast

Click Apply and Ok. option + cmd + L to format a file.

Refactoring

Copy lines which you want to refactor. Refactor>Refactor this or ctrl + T. Select appropreate choice such as Method... or type met to filter. It will show a panel Extract Method. Select Visibility, Public, Protected or Private. Type a Name. It will create a method and replace the original with a new method name.

Renaming a method

ctrl + T and select Rename. It will show a panel at the bottom to show all occurences. Click Do Refactor to complete.

Moving a method to a base controller

Refactor to create a method. Move a cursor to the new method and ctrl + T, select Pull Members Up. And confirm Pull up members of ... to: BaseController. Then click Refactor to move the method to the parent controller.

Extract interface refactoring

  1. Rename a class

ctrl + T > Rename. This will change the file name automatically as well.

  1. Extract an interface, have the class implement that interface.

ctrl + T > Interface. This will display Extract Interface From Class ... Type Interface Nmae, Namespace and select Members to form interface. Click Refactor. This will add comments at the top of the file.

To modify the comments, cmd + , > file template > PHP Interface, delete #parse("PHP File Header.php").

<?php

#if (${NAMESPACE})
namespace ${NAMESPACE};
#end

interface ${NAME} {

}
  1. Have the class implement that interface.

Clone this wiki locally