PHPStorm

Useful shortcuts

Shift ⌘O spotlight like to get files

⌘O Find file by ClassName

⌘E Navigate to recent files

⌘L Go to specific line

⌘B Go to declaration of variable

How to auto style PHP code to follow PSR1/PSR2

1) Go to Preferences.

2) Search for Code Style

3) Choose PHP

4) Click on Set From..

5) Choose PSR1/PSR2 as show below:

phpstorm-psr1_psr2

Doctrine load fixtures – How to load particular fixture

Symfony has an option to load fixtures from command line:

$ php app/console doctrine:fixtures:load --help
Usage:
 doctrine:fixtures:load [--fixtures[="..."]] [--append] [--em="..."] [--purge-with-truncate]

Options:
 --fixtures             The directory or file to load data fixtures from. (multiple values allowed)
 --append               Append the data fixtures instead of deleting all data from the database first.
 --em                   The entity manager to use for this command.
 --purge-with-truncate  Purge data by using a database-level TRUNCATE statement
 --help (-h)            Display this help message.
 --quiet (-q)           Do not output any message.
 --verbose (-v|vv|vvv)  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug.
 --version (-V)         Display this application version.
 --ansi                 Force ANSI output.
 --no-ansi              Disable ANSI output.
 --no-interaction (-n)  Do not ask any interactive question.
 --shell (-s)           Launch the shell.
 --process-isolation    Launch commands from shell as a separate process.
 --env (-e)             The Environment name. (default: "test")
 --no-debug             Switches off debug mode.

But if you assign the full path to fixture file with --fixtures option, its not going to load it and you’ll end up with error:

[InvalidArgumentException]
Could not find any fixtures to load in:
– full/path/to/file.php

The other option is to load the folder itself by typing the full path to folder where fixture file resides.

php app/console doctrine:fixtures:load --fixture=/src/BundleName/DataFixtures/ORM/

Restarting Redis

To restart redis, you need to AUTH from redis-cli and run:

shutdown

then exit, run

service redis start

To find the password for your current redis installation, open the following file:

vim /etc/redis/6379.conf

search for the line required pass

Run Redis commands from command line without logging to redid-cli

To run a redis command from command line:

Show all keys:

/usr/bin/redis-cli keys '*'

Remove all keys:

/usr/bin/redis-cli FLUSHDB

Further info:

  • http://stackoverflow.com/questions/7537905/redis-set-a-password-for-redis
  • http://stackoverflow.com/questions/6910378/how-can-i-stop-redis-server