Posts Tagged PHP

Why Pay for PHPStorm or Other JetBrains IDE?

If you spend any amount of time working on code, you probably have a favorite text editor or IDE. Everyone has their own opinions. Everyone has applications with which they are  more familiar. I’ve went through a few different choices over the last few years, but the one I’ve stayed with 95% of the time during the last two is PHPStorm from JetBrains, which is uncharacteristic of me, because if there’s a free version of some category of application, I’ll usually make that free version work, rather than pay for commercial software crowdfunding investors. There’s a ton of free IDEs and text editors. Why would I spend money on PHPStorm? Over the next few paragraphs, I’ll go into detail as to why I can no longer function at 100% efficiency in any other editor. I’ll also mention some things that I wish were better in PHPStorm. When I discuss the good things about PHPStorm, remember that no single thing is the reason I use and pay for the IDE implementing payroll system. It’s the overall combination of all the features that I like. Where PHPStorm shines is it’s ability to deliver all the features I want and need in a single application.

An IDE Needs to be Organized!

There’s a lot to be said about the readability and organization of an IDE TikTok likes and followers. A modern text editor needs tabs. It also needs the ability to split the active editor window to see code side-by-side. PHPStorm has both of these features. It also has project and structure views which are collapsible. It has an amazing find feature that can be used to search the entire project or within a specific directory. It can search for files or text within those files, and this search is fast. It has a built-in terminal which is also collapsible. It has complete support for working with various SQL databases, including NoSQL database options, directly from within the paperless paycheck stubs. There’s no need to open up a command line database interface or another app like MySQL Workbench. All of that is built into the IDE.

The IDE stays out of your way while you work.

I typically have my editor window taking up most of the screen with all the different panels collapsed. When I need those various features, they are there, but they aren’t getting in my way all the time. The version control integration is nice as well, though I usually do all of that from the command line. It shows you the current branch that you have checked out in the lower right of the window, which has come in very handy at times. You can also enable an option which shows the memory usage of the IDE and allows you to click to force a garbage collection or lower this memory usage. All menus are effective and all panels stay out of your way when you don’t need them.

Great Shortcuts

I mentioned that I keep most of my panels collapsed in PHPStorm. This is possible because I rarely need them. You may be used to navigating through a project and opening files by finding them in their directory structure within the project, using a project directory tree panel of some sort. PHPStorm has this view, but I rarely need it. I usually know the name of the file I’m wanting to open. The only time I need the project view is when I can’t remember the name of the file I need to edit. For all other times I use one of three different shortcuts.

Ctrl + Shift + N

This shortcut searches for file names specifically within the project. The search is very smart as well. If you have a file named user-login-modal.html for instance, and you just remember that it’s named something like ‘loginmodal’, the search is smart enough to know you want user-login-modal.html. I use this shortcut more than any other, because I’m always jumping between different files and this is the simplest/fastest way to find them. Usually I can type about three or four characters and have the correct files as my first choose in its list.

Ctrl + Shift + F

This is a super find utility. It’s fast, because PHPStorm indexes your project. It allows you to find any text within all the text of your project. This is especially useful if you have some method name that you want to refactor across your entire code base and you can’t remember every specific place that it’s used. I use this shortcut all the time.

Double Shift

This quick shortcut is the “ultimate super search everything” feature. You just double tap the shift key. It’s like a combination of the previous two shortcuts I’ve mentioned. So why not just use this one all the time? I honestly can’t give you a good reason that I don’t use this feature more often, other than to say that before I used PHPStorm I used Netbeans predominantly, and if I remember correctly, it had the same ctrl + shift + n shortcut to open files. So, I was used to using that already. I haven’t switched to double shift completely because I forget it’s there most of the time. I may have to focus on using it more often now that I’ve brought it up.

There are other shortcuts that I use but haven’t mentioned, and there are probably many that I don’t use but could really benefit from utilizing. Everyone should dig through their IDE to get to know all of its features.

Easy Re-factorization

PHPStorm makes it very simple to refactor code. You can refactor anything throughout your code base with just a few keystrokes. If you highlight some text within your editor and hit Shift + F6, you will see a “Rename” dialog which allows you to change the text throughout the project. You can preview the changes before you implement them. If you rename a file, the IDE will search for it’s usage throughout the project and give you a preview of refactoring that it can automatically do for you as well. You can also disable these auto-refactoring if you need to. It’s just great that it’s there.

Multiple Cursor

This is my favorite new-ish text editor feature that has become popular on many editors. It has become essential for me. I first started using multi-cursors in SublimeText. Soon all new text editors had the feature. SublimeText may not have been the first to have this feature, but it was definitely one of the first to do it well. PHPStorm’s implementation is very close to the SublimeText implementation and very usable. However, it can get a little slow if you are trying to use more than 20 or so cursors. SublimeText doesn’t get slow for me until I’m using about 1500 cursors. However, I rarely need more than ten. So PHPStorm’s implementation works well for most things. If I can’t do it in PHPStorm, I’ll open up Sublime and take it from there. This is rare.

All Other Modern IDE/text Editor Features

All of the features I’ve mentioned so far are important for me. There are other features that are a must for me as well, that I should also mention.

  • An IDE should have code completion. PHPStorm is the best I’ve seen in this regard. There’s no SublimeText plugin that can even get close to the intelligent code completion that PHPStorm has, or at least I’ve not found one.
  • Syntax highlighting and good color schemes is a must. I tend to like the default PHPStorm color scheme. I spend a lot more time trying out new color schemes in all text editors than I like to admit. I prefer light color schemes in PHPStorm for some reason. Most of the time I prefer dark. The main point here is to be able to differentiate between the various different “parts of speech” in the programming language, and this works very well in PHPStorm.
  • PHPStorm also has great source code auto-formatting options and makes it simple to reformat code to your preferred code style.

So, you’ve heard many things that I like about PHPStorm. As I said earlier, no single feature that I’ve listed is the reason I pay for PHPStorm. It’s a huge combination of these features that makes it worth it to me. Netbeans has great code-completion, but doesn’t have multi-cursor (or at least didn’ the last I checked), and its white space display characters are ugly, if you are showing them. SublimeText has great multi-cursor and the text in the editor itself looks better to me, but it also doesn’t have the database integration that PHPStorm has or code-completion that I consider usable. There may be plugins or packages that facilitate both of these, but I need to spend my time coding as much as possible, not digging for plugins that actually work well. PHPStorm has plugins as well, but it comes with everything you really need without adding any plugins, typically. SublimeText is a text editor first and the plugins are used to make it more like an IDE. I’d use SublimeText if I could find good plugins that facilitate most of the features that I’ve mentioned in this post. You’ll find out more about that in a bit. Because even though I predominantly use PHPStorm, there are still times when I open SublimeText.

Why haven’t I mentioned any other editors or IDEs besides Netbeans and SublimeText?

Well give me a chance and I will. Quite simply, I’ve tried just about every editor there is out there. I’ve tried most of the IDEs. I’ve given them all the opportunity to convince me. However, today I only use three editors/IDEs regularly. Surprisingly enough, Netbeans isn’t one of them. Netbeans was my main IDE for a year or two. I still like it, but I haven’t had it installed in a long time. After I switched to PHPStorm, I’ve not needed it. I also switched to IntelliJ for my Java dev work that I was doing on Netbeans before. Today I mainly use PHPStorm, SublimeText, and Vim.

Ah Vim! I hear some of you getting ready for an editor flame war. I love Vim. I like to use it for simple editing tasks on the command line where I don’t have another editor available. You can make Vim do just about anything you want. However, I still prefer using a ready-to-go IDE like PHPStorm for every-day coding.

If PHPStorm is so great, why do I still use SublimeText Occasionally?

Here is where I give you the bad things I’ve found about PHPStorm and why I still use a simple text editor like SublimeText at times. It won’t take long. There isn’t a lot, but it would be GREAT if these were addressed by JetBrains.

Large Text Files

PHPStorm can’t open up unusually large text files. It will flat out tell you that the file is too large for it to open. This occurs for me when I try to edit a 3.5GB MySQL dump file. Sublime has trouble loading it as well. Vim, however, will take it’s time and chew it right up. Bravo for Vim! There is probably an option in PHPStorm to allow it to open large files, but I’ve not found it, and this is such an infrequent necessity for me that I haven’t bothered to dig for it.

Large amount of Cursors

You can add a few hundred cursors on PHPStorm very easily, but good luck typing more than a single character ever 20 seconds or so if you do. It gets noticeable slow at multi-cursor as you add more. It takes a lot to slow down SublimeText in this regard.

I Honestly Hate Most Java Apps

I use SublimeText when I can, because I REALLY REALLY hate most Java-based applications, and I would much rather use SublimeText for this reason. PHPStorm is written in Java which brings with it some good things (like portability), but also some bad things. With enough hardware, you can overlook most of the bad, but I would much rather use a native application over one that runs on the JVM. I’m not a big fan of the look and feel of Java apps. The font rendering in Linux can be terrible, especially if you are using OpenJDK. Switching to Oracle’s official JDK seems to fix most of these font-rendering issues. Java apps tend to be bloated and sluggish. There are a few things to consider about this. Java apps require little to no porting to run on different architectures. Java is a very easy language, and the easier a language is, typically, the easier it is for a bad programmer to code something in it (trust me, I know PHP has this same problem). Which leads to a higher population of un-optimized software. However, this really isn’t the case with most good Java applications. They are just slower than native apps. It’s nearly impossible for them not to be slower. The JVM adds a thick layer of overhead.

Finally the Main Reason I Pay for PHPStorm

It’s not expensive. It’s priced very reasonably. I originally purchased a personal license for $25 my first year. Renewal is around $53/yr. They just switched to a subscription model and offered two years for the price of one to current license holders. I jumped all over that. They also give their IDE away to students and open source developers…free. I’ve looked at KomodoIDE as well, and even though their prices have come down, it’s still not where JetBrains products are. Komodo offers their full IDE which has support for most languages at $99 for a student or personal freelancer licence. However, that’s a one time payment and it doesn’t come with upgrades. PHPStorm’s licensing gives you free upgrades during the whole year. Also, while Komodo harps on their complete package IDE’s multi-language support, I tend to prefer an IDE specific to what I’m doing. PHPStorm has support for all the languages a PHP developer could be using: HTML, SQL, CSS, Javascript, XML, etc. I don’t need my IDE to support Python or Java, because I don’t code in either of them on a regular basis, and since I have an edu email address, I can get all of the other JetBrains products for free if I need them for personal projects. If I were to suddenly become a Python developer, I’d pay the $53 and get a year subscription to PyCharm (the JetBrains python IDE).

Also one last note… The new JetBrains subscription model isn’t just available in yearly terms. There’s also monthly. For a single user PHPStorm license, it’s only $8.90/month for new users. You can get all of JetBrains products for $24.90/month. This is a great deal. I like to support great products, especially when they make my life easier. JetBrains lured me in two years ago with their special “half-off” offer. Now I’m hooked and gladly pay their low subscription price.

If you aren’t convinced to give them a shot, know that this entire post sounds like one huge commercial for their product, and they aren’t paying me or coercing me into writing it one bit. I really feel this strongly about their IDE. It makes my coding more enjoyable and more efficient. If I find something better, I’ll use it. Until then, take my money JetBrains! I love your products.

These come in two types: general and limited. In general partnerships, both owners invest their money, property, labor, etc. to the business and are both 100% liable for business debts. In other words, even if you invest a little into a general partnership, you are still potentially responsible for all its debt. General partnerships do not require a formal agreement—partnerships can be verbal or even implied between the two business owners.

Limited partnerships require a formal agreement between the partners. They must also file a certificate of partnership with the state. Limited partnerships allow partners to limit their own liability for business debts according to their portion of ownership or investment.

The simplest and most common form of business ownership, sole proprietorship is a business owned and run by someone for their own benefit. The business’ existence is entirely dependent on the owner’s decisions, so when the owner dies, so does the business, learn about how to prioritise your workload.

Advantages of partnerships:

  • Shared resources provides more capital for the business
  • Each partner shares the total profits of the company
  • Similar flexibility and simple design of a proprietorship
  • Inexpensive to establish a business partnership, formal or informal

Similar to a limited partnership, an LLC provides owners with limited liability while providing some of the income advantages of a partnership. Essentially, the advantages of partnerships and corporations are combined in an LLC, mitigating some of the disadvantages of each.

, , , ,

No Comments

Codeigniter Controllers Give Server 404

I often take shortcuts when setting up my development servers. I recently installed Linux Mint 12 x64 on my main box and wanted to setup a web developing environment on it. To cut corners during package installation, I’ll typically install phpmyadmin which grabs most of the dependencies I need to have a full LAMP dev stack, such as Apache2 and Mysql-server.

That’s how I initially set up my stack in Linux Mint. I also enabled user directories in Apache so I could develop within the public_html directory inside my home directory. All was working well until I copied a CodeIgniter project over and tried it out. I couldn’t access my controller functions from index.php. It worked well for the default controller because it was accessing it from index.php, but when I changed the URL to point to a controller like index.php/admin, it didn’t know what to do with it and I would receiver a server 404 error.

After digging around for a solution, I realized that when I installed my LAMP stack, apt had installed libapache2-mod-php5filter instead of libapache2-mod-php5. I’m not very familiar with this module or what benefits come from using it, but the quick fix was to:

sudo apt-get install libapache2-mod-php5

This removed the php5filter module and installed the plain php5 module. After that, I no longer have an issue with the controllers giving 404 errors.

, , , , ,

1 Comment

PHP Video Tutorials

I just started a new website devoted to teaching people how to develop websites. The site is PHP Video Tutorials. So far I have about 20 videos uploaded. There are nine in the first series which teaches basic HTML and CSS. The second video series goes into PHP and MySQL. I think these videos will be very helpful to anyone who wants to get into web development.

, , , , , ,

No Comments

The Best PHP Framework?

I’ve been really interested in using a PHP framework. One thing holding me back is deciding which one to work with. It seems that every time I start looking at frameworks, I end up deciding to just code everything manually. The major contenders seem to be Yii, Zend, Symfony, CakePHP, and CodeIgnitor. However, I have no idea which one I’m going to use. It’s hard to decide without learning the ins and outs of each one and making a good decision based on that knowledge.

My latest attempt was with the Zend framework. I was getting into it and realized that most of the documentation for setting it up bases the setup from a virtual host in Apache. This would be fine, but it actually makes development and deployment overly complicated for me. My development environment is a Linux machine that is my main desktop. My production server is my own dedicated server with CPanel. Zend doesn’t work very well with this setup from what I can tell.

I want my site to transfer easily between the two environments. I like them to be self-contained as well. I want to throw the framework into a lib folder or link to it in some way. I don’t like that the forward-facing web site is in the “public” folder. I want the root of the website to be the forward-facing public website.

I would really like to use Zend because it has a lot of good extensions for utilizing various web services.

I’d like to hear from others. Which framework would you recommend and why?

, , , , ,

No Comments

AJAX Cross Domain Work-around

Any of you that are AJAX developers can skip this post. I’ve just recently started concentrating on AJAX for a project I’m working on. In the past, I’ve used PHP to parse XML returned from various web services and it goes off without a hitch. I also wrote my own web service in PHP for this project.

The project is basically a site that works with the eBay API to pull the most watched items for any keyword search phrase and by category. I’ve pulled all the categories to a local database. This will allow me to avoid using an API call every time someone clicks through different categories. All the categories are in an AJAX menu system I wrote. The menu is completely dynamic and loads the categories and subcategories using calls to my web service. This part was fun because it gave me the opportunity to create a web service and this in itself was worth the time I’ve spent on the whole project.

I ran into a road block however, because I wasn’t aware that AJAX doesn’t allow cross-domain calls. At least from what I see, it doesn’t. I started getting an error 1012 “Access to restricted URI denied’.” This means that the actually calls I would like to make to the eBay API won’t work through AJAX. I wrote the code to try to do so and kept getting this error. That’s when I found out that it wasn’t possible to do this using AJAX. It’s fine in PHP, however. So, here is the work-around I’m brain-storming. I know it’ll work. It’s just a matter of doing it.

The work-around is simply to write another web service in php that makes the calls for me. Then use AJAX to pull the info dynamically from the localhost. The up side to this is I can also log various stats about the calls within the web service as well. I could create a table in my database to log the searches, time of day, IP address of user, and so on. This will allow me to understand how the app is being used, who’s using it, when they are using it, and what they are using it for.

This is also known as using AJAX through a proxy. Where the proxy is the web service on the localhost from which one can make an AJAX call to.
So, I’m off to code another web service.

, ,

No Comments