PHPStorm is one of the best IDE’s to develop in PHP. I recently came across tons complex php cli scripts and needed a way to debug them.
Most important things to configure are
- Set up xdebug correctly on the remote server. Dont use xdebug.remote_connect_back. Instead use xdebug.remote_host
- Xdebug must be set up for php cli – check with the command php -i | grep xdebug and you should see many entries
- Set up deployment path mapping correctly in your project settings – a lot of people miss this and wonder why debug is not working
- Check your firewalls on both machines, make sure required ports are open, especially port 9000
- Check debugger settings in phpstorm and make sure you have break at first line set up
In the PHPStorm tutorial, it asks you to set up SSH tunnel. If you are not doing tunneling, you should set these environment variables on the remote server
Eg, if my remote server is centos, i will set these 2 variables
export XDEBUG_CONFIG="idekey=PHPSTORM"; export PHP_IDE_CONFIG="serverName=myDeploymentServerName";
serverName is the name of the server you set up for deployment in phpstorm deployment settings
these variables are valid for the session, if you logout and log in, you have to set them again.
You can add these to your .bashrc file in your home folder to make them permanent
In case you want to use xdebug.remote_connect_back, you might have to run your php scripts on the command line with additional args like this
php -dxdebug.remote_enable=1 -dxdebug.remote_host=10.0.1.2 -dxdebug.remote_connect_back=0 /path-to-php-script
Putty is a versatile tool for remote SSH access – however the color schemes are not too impressive. The blue especially is really bad. You can change the blue color in the settings but what if you already have a ton of putty Saved Sessions. You will have to painfully modify each. There is a better way by directly modifying the registry entry for all sessions at once.
I am doing this on Windows 7.
A word of caution, we will be modifying registry entries. I have done this many times without problems, however I will still say, do it at your own risk.
Right, lets get to it then.
Press Windows Key + R to get the Run prompt
Enter regedit and press Ok. This will open the registry editor
Navigate to HKEY_CURRENT_USER -> Software -> Simontatham -> PuTTY
Expand Sessions and you should see all your Saved Sessions listed there
Right Click on Sessions and select Export
Save the file as putty-original.reg somewhere where you can locate it
Dont modify this file, this is your backup file
If something goes wrong or you dont like the changes, you re-import this file and you are back where you started
Make a copy of the file call it putty-new.reg
Open putty-new.reg in your text editor ( i am using notepad++ or sublime )
This will have color value blocks for all your Saved Sessions.
You have to replace the entire color block with the new color block
Replace the color blocks with this new color block – do this for all color blocks
"Colour0"="217,230,242" "Colour1"="217,230,242" "Colour2"="14,27,48" "Colour3"="14,27,48" "Colour4"="14,27,48" "Colour5"="217,230,242" "Colour6"="0,0,0" "Colour7"="46,46,46" "Colour8"="215,49,64" "Colour9"="223,100,112" "Colour10"="80,194,54" "Colour11"="128,202,105" "Colour12"="215,184,54" "Colour13"="223,194,105" "Colour14"="58,91,199" "Colour15"="97,127,204" "Colour16"="206,49,199" "Colour17"="216,100,207" "Colour18"="71,194,189" "Colour19"="122,202,200" "Colour20"="211,211,211" "Colour21"="255,255,255"
Once you have replaced blocks for all sessions in the file, save putty-new.reg
Double click on putty-new.reg to import the new settings.
Windows will ask for permissions and display warnings, go ahead click ok
Exit out of your current putty sessions and re connect.
You should see the new colors and color scheme.
If something went wrong, or you did not like the color scheme, double click putty-original.reg to get back to your old settings.
Keep putty-original.reg safely.
There are many links on the web which will let you build your own color schemes – try them
This color scheme I found here
There are 2 ways to set up periodic cron jobs in linux
- Put them directly in the crontab
- Put them in one of the cron directories – below are available
/etc/cron.hourly /etc/cron.daily /etc/cron.weekly /etc/cron.monthly
So you can create a script and put it in one of the directories and they will run according to schedule
For example, if i put a script in cron.hourly, it will be executed hourly etc
Before you do that, you have to take care of the below things
- Make sure your script does not have an extension, else cron might ignore it. If you have a script named myScript.sh, just rename it to myScript
- Make the script executable, use sudo chmod +x myScript
- If using bash script remember to declare the #!/bin/bash at the top
Once you copy your script to the required directory, use this utility to test and see if cron will execute your script ( change cron directory as required )
sudo run-parts --test /etc/cron.hourly
Your script should show up here – else it wont be run
The default audio recorder in Win 7 save the file as WMA. However, you can use this simple command to record audio and save to WAV instead
Go to Start Menu search bar and type the below command and hit enter
soundrecorder /file output.wav
If you work on the mysql command line, its nice to have an autocomplete similar to the linux bash where you press the TAB key and the commands complete.
In mysql, we can set it up to a degree to provide some hints when we type. Though it might not complete everything you type, it does complete table names etc.
2 ways to do it ( I am on CentOS 6.5 )
when you log into mysql, use the auto-rehash config option like
mysql --auto-rehash -u root -p
if this does not work, then try creating a file called .my.cnf in your home directory and put the below into it
On Linux, if you have logged into mysql on the command prompt and want to clear all text on screen you can use
mysql> \! clear
\! system-command is the command format
\! tells mysql to pass the command to the system
[naveen@localhost ~]$ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 Server version: 5.1.73-log Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | drupal | | employees | | mysql | | phpmyadmin | | test | | zabbix | +--------------------+ 7 rows in set (0.00 sec) mysql> \! clear
You must be on localhost and have Linux root permissions
I had to create a MySQL account for myself on a Linux box. So here it is
# kill the running mysql process sudo service mysql stop # start mysql in safe mode and skip grant tables sudo mysqld_safe --skip-grant-tables --skip-networking & # log in with root mysql -u root # ( optional ) flush privileges, create new user, grant privileges FLUSH PRIVILEGES; CREATE USER 'new-user'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON *.* TO 'new-user'@'localhost' WITH GRANT OPTION; FLUSH PRIVILEGES; exit; # stop mysqld_safe process ps -A | grep mysql sudo kill < mysql-pid-here > # start mysql normally sudo service mysql start