Sublime Text 3 perfect PHP development set-up

Sublime Text 3 perfect PHP development set-up

This is follow-up arti­cle to Sub­lime Text 2 per­fect PHP devel­op­ment set-up. I decided to write this updated ver­sion, because from some time now Sub­lime Text 3 is out there. Maybe it is still offi­cially beta, but works pretty sta­ble and I’m using it for few months now.

This list is almost the same as in pre­vi­ous arti­cle — most of plu­g­ins I used with ST2 have been updated in order to work with ST3 and I stopped using few of them, so they are out. I’m kinda lazy, so some of descrip­tions are copy-pasted from pre­vi­ous article ;)
Any­way, here is the list:
  1. Pack­age Con­trol (
    Thanks to this lit­tle piece of soft­ware all other plu­g­ins are eas­ily installed.
  2. Sub­lime­CodeIn­tel (
    This is pack­age I use all the time. Its job is to pro­vide hints related to func­tion, object, vari­able etc. names. It also hints what meth­ods and para­me­ters are avail­able in objects/classes. It’s based on Komodo CodeIn­tel and some­times it has some prob­lems work­ing at all. But most of the time it rocks :)
  3. Sub­limeLin­ter (
    This pack­age does full-time job for me — it con­stantly watches what I write and instantly lets me know if some­thing is not OK, for exam­ple I for­get semi-colon or brackets.
    From ver­sion 3 and up, Sub­limeLIn­ter has become mod­u­lar. This means, that you have to install main pack­age first, and then plugin/module for every lan­guage you need sup­port for. Each plu­gin has it’s own set of require­ments, so please make sure you read them thoroughly.
    For PHP + JavaScript devel­op­ment I’m using:
  4. Side­BarEn­hance­ments (
    Pro­vides great new options when right-clicking on side­bar ele­ments (files/folders). Very convenient.
  5. VCS Gut­ter (
    Lately I don’t imag­ine work­ing with­out this one. Every day I use Git and Mer­cu­r­ial and this plu­g­ins gives me real-time infor­ma­tion about what was changed (or added/removed) in cur­rent file using sym­bols in left-hand edit win­dow gutter.
  6. SFTP, paid (
    Great pack­age enabling very com­fort­able use of SFTP, FTP and FTPS. It sup­ports remote fold­ers brows­ing, edit­ing and syn­chro­niza­tion between local and remote files. Also reg­u­lar upload, down­load pn save or file open.
  7. Tor­toise (on Win­dows only) (
    I use it as a com­ple­men­tary pack­age to Side­Bar­Git if I’m work­ing in Win­dows envi­ron­ment. It doesn’t have so many fea­tures but those what it pro­vide are very help­full and intuitive.If you like Tor­toise Git but you are work­ing on Linux you might want to check out Rab­bitVCS. It isn’t inte­grated with ST2, but it pro­vides com­fort­able right-mouse-click Git GUI.
  8. sublime-github (
    Every devel­oper should use code snip­pets of some kind. I use Gist pro­vided by GitHub and this pack­age enables me to use them instantly (save/paste).
  9. Tag (
    It is fine plu­gin, but now ST3 sup­ports tag match­ing, so I don’t need it any more.
  10. Php­Doc (
    Great plu­gin aid­ing writ­ing doc­u­men­ta­tion docblocks for PHPDocumentor.
  11. Phpcs (
    This pack­age adds sup­port for PHP_CodeSniffer to ST2. It checks if you code is writ­ten accord­ing to one of the stan­dards. Just pick one: Zend, PEAR.. and more :) Check out PHP_CodeSniffer web­site for con­fig­u­ra­tion details.
  12. Trail­ing­Spaces (
    Small hor­ror of every code — empty spaces at lines ends, at the end of file. Espe­cially trou­ble­some if you are work­ing on the code with other devel­op­ers, who might use dif­fer­ent editors/IDEs which might inter­pret them (empty spaces) differently.
  13. Brack­etHigh­lighter (
    Same sit­u­a­tion as with Tag plu­gin. In my every­day cod­ing ST3 bracket high­light­ing capa­bil­i­ties of ST3 are good enough. It is still great plu­gin though.
  14. Sub­lime Func­tion Name Dis­play (
    Dis­plays in bot­tom bar name of a func­tion (or method) in which our cur­sor is placed. Sim­ple and helpful.
  15. Ter­mi­nal (
    Using Git or maybe some PEAR pack­ages you might need to switch to con­sole from time to time and do some magic. Maybe use Zend Tool or “bake” some­thing ;) It’s just what this plu­gin is for.
  16. Xde­bug Client (
    Lately my favorite Xde­bug client for ST3. Works great and allows to use all of Xde­bug debug­ging capabilities.
Few sup­port­ing pack­ages. I con­sider them optional, but they come in handy:
  1. LineEnd­ings (
    Nice to have plu­gin if you are work­ing with other devel­op­ers using Win­dows and Unix/Linux machines. It takes care of dif­fer­ent (invis­i­ble) line end­ing char­ac­ters in those systems.
  2. Sass (
    This one comes in handy when work­ing with Sass files. Syn­tax high­light­ing and so on.
  3. Plain­Tasks ( added thanks to Virion’s com­ment
    Great tool for every­one who like to have their tasks orga­nized, flex­i­ble with many great features.
  4. Sub­limerge ( thanks to Virion’s com­ment
    Diff tool on steroids. Ideal for every­one who has to do a lot with merg­ing, espe­cially use­ful when it comes to large files.
  5. Dash­Doc ( only)
    This one is for Mac users only and only for those who have Dash installed, but I really rec­om­mend it. Dash pro­vides access to docs of almost every major library, frame­work etc. and so much more! With this plu­gin you can access it directly right from Sub­liem Text code win­dow with key­board short­cut. It really speeds up coding.
That’s it for now. I might come back and some­thing later, but this is my set-up and works great for me.


How to create and execute JAR file in Java – Command line Eclipse Netbeans

Creating JAR file in java from command prompt is always been little tricky for many of us even if IDE like Netbeans and Eclipse provide support to export java program as JAR file simply because we don’t create jar often and not familiar with manifest file or jar command as whole. JAR file in Java is a kind of zip file which holds all contents of a Java application including Class files, resources such as images, sound files and optional Manifest file. JAR stands for Java Archive and provides a platform independent deliverable for java programs, libraries and framework. you can execute same jar file in any operating system e.g. Windows 7, windows 8, Macintosh or Linux. Apart from platform independence and standard delivery method jar file also provides compression of contents which results in faster download if you are downloading java program from internet specially in case of mobile devices where you install Java program by OTA. In this article we will some JAR command examples and learn how to create and execute jar filehow to view contents of jar file from command prompt and Eclipse and Netbeans.

How to create jar file in Java form command prompt

Example to create and execute JAR file in Java from Command line Eclipse and Netbeansjar command in Java allows you to create jar file from command prompt, what is required is that you must have jar command included in System PATH variable. you can check this by typing "jar" in command prompt if it doesn't throw error as "jar is not recognized as an internal or external command" they you are ready to go. When you create jar file in Java, command also creates Manifest file which is optional and you can control whether to create it or not by jar command line options, but if you want to create executable jar file they you must need Manifest file which we will discuss in further sections. Now here is jar command example to create jar file from command prompt, this will work both in windows and Linux operating system.

JAR command Examples in Java

javin@localhost:~/Java jar -cvf HelloWorld.jar HelloWorld.class
added manifest
adding: HelloWorld.class(in = 450) (out= 311)(deflated 30%)

This command will crate Helloworld. jar which contains Helloworld.class file. this will also create manifest file but without Main-Class entry as shown below:

javin@localhost:~/Java cat MANIFEST.MF
Manifest-Version: 1.0
Created-By: 1.6.0-beta2 (Sun Microsystems Inc.)

This jar can not be executed and you will get error when you try to run this jar file:

javin@localhost:~/Java java -jar HelloWorld.jar
Failed to load Main-Class manifest attribute from HelloWorld.jar

You just need to provide Main-Class entry to get rid of this error which we will see in coming Section.

How to Create an executable JAR file in Java

To create an executable JAR in Java, you need to provide a manifest file and include your Main Class in Manifest. When you create jar file , jar command also creates manifest file inside META-INF as MANIFEST.MF but doesn't create Main-Class entry which is required for executable jar file. You can create executable jar file in Java by two ways either provide a self created Manifest file or specify entry point using "-e" jar option. If you provide external Manifest file than you need to use jar -m option to include that manifest file inside jar. Let's see example of both ways to create executable jar file in Java.

Executable JAR File Example with External Manifest

1.Create MANIFEST.MF file by using any text editor e.g. notepad in windows or Vim in Unix and add following entry in file, remember last line must end with either new line or carriage return:

Manifest-version: 1.0
Main-Class: HelloWorld

Important thing to remember is that we need to specified full classified class name here. suppose if our main class was inside com/example/HelloWorld than we should have to specify com.example.HelloWorld here, don't put .class extension here its not required. Apart from specifying Main-Class you can also specify Java Classpath in Manifest file which is important if your application is depended on external library jars. "Classpath" entry supersede both -cp and CLASSPATH environment variable. to learn more see How ClassPath works in Java.

2.Execute following jar command to create executable jar

javin@localhost:~/Java jar -cvfm HelloWorld.jar MANIFEST.MF HelloWorld.class
added manifest
adding: HelloWorld.class(in = 450) (out= 311)(deflated 30%)

here -m is used for including manifest file and remember specify name of manifest file after jar name. now you have an executable jar file in java which you run by command specified earlier.

Creating Executable JAR File By entry point

This seems to me an easy way to create executable jars in Java, as you need not have to create manifest file explicitly and it will be create by jar command itself along with Main-Class entry. What you need to provide is a new jar option "-e" and you main class name while running jar command. here is example of jar command with entry option:

javin@localhost:~/Java jar -cvfe HelloWorld.jar HelloWorld HelloWorld.class
added manifest
adding: HelloWorld.class(in = 450) (out= 311)(deflated 30%)

jar -e for entry point and entry point or main class name should come after jar file name and before directory or file needs to be included in JAR. You can now run your executable jar file by issuing "java -jar" command as shown in following example:

javin@localhost:~/Java java -jar HelloWorld.jar
Executing Java Program from JAR file

How to execute Java Program from Jar file

Executing jar program from jar archive is very easy one thing required is jar must be executable and must have Main-Class entry in MANIFEST.MF file. here is a Java command example for running java program from jar file:

javin@localhost:~/Java java -jar HelloWorld.jar
Executing Java Program from JAR file

here we have specified jar file name with -jar option and it will run main class declared as “Main-Class” attribute in manifest file.

How to view contents of a JAR file in Java

jar command in Java allows you to view files and directories inside of a jar file without extracting or unzipping original jar. "-t" jar option is used to list files from jar archive as shown in jar command example below:

javin@localhost:~/Java jar -tvf HelloWorld.jar
0 Wed Dec 07 22:36:12 VET 2011 META-INF/
95 Wed Dec 07 22:36:12 VET 2011 META-INF/MANIFEST.MF
450 Wed Dec 07 21:36:04 VET 2011 HelloWorld.class

here "-t" for listing and "-v" and "-f" for verbose and jar file name.

How to extract contents of JAR File

use jar option "-v" for extracting files form JAR files as shown in jar command example below:

javin@localhost:~/Java jar -xvf HelloWorld.jar
created: META-INF/
inflated: HelloWorld.class

here -x for extracting , -v is for verbose and -f specify jar file name.

How to create jar file in Eclipse

Creating JAR file in  Eclipse IDE is a cakewalk once you know the process. here is step by step guide of creating JAR file from Eclipse IDE: In Jar file main class is specified as “Main-Class” attribute inside manifest file and used as program entry point if you double click on JAR or run jar from java command.

1) Select Project for which you want to create jar file.
2) Go to File Menu and select Export
3) Expand Java folder and select JAR file

Now you just need to click next and follow instruction as displayed. you can select what contents you want to export to jar file and specify Main Class entry as well. If you like Eclipse IDE then you may like my earlier post on eclipse as well e.g. Java debugging tips in Eclipse and  How to setup java remote debugging in Eclipse.

How to create jar file in Netbeans

In Netbeans to create jar file you need to build the project which execute project ant file and creates JAR file inside dist folder. You can go on properties of project and specify main class there which will be run when you run the project and same will be used to create “Main-Class” attribute in JAR file.

jar is not recognized as an internal or external command

if you get this error while executing jar command from command prompt in Windows or Unix it means your Java Path is not set properly. JAR command is a binary which resides in JDK_HOME/bin folder where JDK_HOME is JDK installation directory. In order to use jar command from command prompt this bin folder must be in your System's PATH variable. Don't worry if its not there in PATH you can check this link to Set PATH for Java in Windows and Unix.It shows how you can do it in both Windows and Unix. Once your PATH is property set, you will see following output when you execute jar command from command  line:

javin@localhost:~ jar
Usage: jar {ctxui}[vfm0Me] [jar-file] [manifest-file] [entry-point] [-C dir] files ...
-c  create new archive
-t  list table of contents for archive

and now you are ready to use jar from command prompt.

WAR and EAR -  related JAR like fies in Java

WAR file
WAR file in Java stands for Web application archive and it is used to package a Java application together you can package all your ServletJSP, CSS, images, html in one WAR file and then deploy it to any Java web or application server like Tomcat, Weblogic or webshere. WAR files provide a clean and faster way to package and deploy Java web application just like JAR file provides for core java apps. Since WAR file also compacts resources inside it is comparatively download faster than downloading individual components.

EAR file
EAR file stands for Enterprise Java Archive and used to package an Enterprise Java application, like earlier WAR and JAR file. What separates EAR archive to WAR file is inclusion of Enterprise Java Beans(EJB). EAR file contains all web resources including Servlet, JSP, html, javascript, css, images along-with EJB. You can not deploy EAR files into web servers like Tomcat because it doesn't support EJB and can only be deploy-able in Application servers like WebSphere or Weblogic.

JAR File format in Java

Few words about java jar file format, its similar to zip format and use .jar extension. you can open JAR file in windows by using either winzip or winrar zip utilities.

That’s all on how to create jar file from command line, Eclipse, Netbeans. How to extract contents, how to run Java program from jar file etc. Let me know if you face any issue while creating JAR file in java.

Read more:

Send Email With CodeIgniter

Send your email forwarding from guestbook maybe or ticketing support with CodeIgniter Email Library or using third party server.
case if using Mandrill
Sending Email from CodeIgniter with Mandrill
The last time I used CodeIgniter in my project was about two years ago. It was an online property marketplace where people can collectively buy expensive houses by sharing ownership of the house and, of course, sharing the mortgage. There was these times when I had my dead-end building an application module to send email to customers, some sort of news letter. The dead-end was actually due to google SMTP limitation on relaying email from my application. If you are on a project that still rely on Google's SMTP to send email, I suggest you migrate to Mandrill.
Mandrill is a transactional email platform from MailChimp. By definition Mandrill is a transactional email platform, which can use to relay emails from our application. Of course there is a price for their services, but as long as we are sending less than 12,000 emails per month we are eligible for free services. It is easy though to scale up if we need to send more than 12,000 emails in a month. Just upgrade your package without re-signing-up your account.
CodeIgniter Mail Library

In order to get our mailing module work, we need to register to mandrill to get our SMTP credentials. To do so, go ahead and open your favorite browser (mine is Chrome) and enter at the address bar.
Click the Sign Up button to create a new account on Mandrill. This is very easy because all you need to fill is just your email address and your Mandrill password. Note that your mandrill password is not your SMTP password.
After signing up, there is going to be an optional profile form that you may or may not fill. I will skip this form for now by clicking the No, Thanks button on the left bottom of the form.
Next step is to click the Get SMTP Credentials button.
 And then type in your Mandrill password when prompted.
Mandrill will create and display your SMTP account detail afterward. Now, to get your SMTP password, click on the + Add API Key button below your SMTP credentials.
Up to this point you should see a new API key. This key (or one of these keys, if you have more than one) can be your SMTP password.
Go on and replace those hash-tags on our email configuration. Go to directoryapplication/config/ and open file email.php, then edit the file matching your Mandrill SMTP credentials.
$config['smtp_host'] = '';
$config['smtp_user'] = '';
$config['smtp_pass'] = 'th1s-1s-y0ur-p4ssw0rd!';
$config['smtp_port'] = '587';
That's it!
Now try to run your script on your browser, and give a comment below if you're having trouble. By the way, to prove you that this tutorial works (even from http://localhost setup on your computer), this what it looks like when I checked my email:
Sample script on Controller Mandrill ThirdParty :

Sample script on Controller with Email Library CI :

note :
If you used Codeigniter, Library can colaborate automatically with config at folder application/config just with 1 condition = file name of library n config is same. If you used hosting for your app or app is gone public, please check your setting on server hosting to combine/allowed port that used (465 google or 587 mandrill)