PHPStorm Quick Tip: Fix reference class not found errors

Sometimes PHPStorm stops knowing about references or locations of class definitions that were working fine previously. Below is an image (click to enlarge) where PHPStorm tells method not found in class even though class file is included and everything is okay:


This may happen due to a bug in PHPStorm (possibly), unexpected system shutdown, system date time modification or some other reason.

To fix it, you just need to change modified dates of files PHPStorm thinks aren’t there. Once you do that, PHPStorm will reload the changes and will be able to get the reference to those files thereby doing away with such errors. You could simply go to a file and modify it by entering space in its contents or if you have good deals of files, the easiest way would be to touch them. The touch is command line utility that comes with Linux OS. If you are using Windows though, you can download it here. Just run below command to touch all files of the project so PHPStorm knows about class definitions and references of them.

touch -m -c -s -R yourProjectFolder

You can see the options of touch utility by typing touch –help.


Automatic git Commit and Push

At times you would like to save some time or find it little boring to repeat same process of committing and pushing to remote git branch; in that case you can find below tip useful. Here is a tip that would help you commit your project changes and push to remote branch with a single click.

Create a file (notice the .sh extension for bash file) and put following contents in it:

cd D:/wamp/www/yourProjectFolder
# switch to branch you want to use
git checkout master
# add all added/modified files
git add .
# commit changes
git commit -am "made changes"
# push to git remote repository
git push
echo Press Enter...

Now put that file under your project folder. When you run it, your changes will automatically be committed and pushed to remote branch. Change the commands accordingly to reflect your branch or commit message. Here is the screenshot of what I get after running above commands:


If you would like to customize the commit message, you would modify the script a bit:

cd D:/wamp/www/yourProjectFolder
# switch to branch you want to use
git checkout master
# add all added/modified files
git add .
# commit changes
read commitMessage
git commit -am "$commitMessage"
# push to git remote repository
git push
echo Press Enter...

And of course, you can add any git commands you would like to automate to that file.

Please notice it is just a tip for those who didn’t know they can automate git commands that way. However, this isn’t usually a good practice; it is always a good idea to review your changes and then commit and push instead of pushing automatically like that. This just turns out to be handy when you are in hurry (or lazy) and are sure about what you are doing.

Please make sure to add PATH environment variable in case script doesn’t work for you.

Introducing WebNote Chrome Extension

I like to read and research and as such I always bookmark interesting articles both locally and online eg Google Bookmarks or some other service. Since we do not always have the time to read an article of our interest the time we come across it, we use online bookmarking services to save and read them later and that’s good.

However, I was looking for a solution which could allow me to save those articles locally on my computer and read them any time later, this is something useful in cases when you are not connected to internet and yet want to be able to have the access to articles you like. I came across Evernote which is pretty cool services you can use to save webpages, videos, voice and a lot more. My primary focus though was to save webpages/articles related to web development. Any page you save to Evernote (via their Web Clipper browser plugin), can be downloaded to your computer via Sync option of that software which is exactly what I was looking for. After using it for a while, it turned out that with FREE account only 60MB is allocated which I consumed within 15 days 😦

As a developer, I thought of creating my own solution that could be used to save articles/pages locally rather than buying Evernote. So I went on to creating the Chrome extension named WebNote.

WebNote can be used to save webpages with all their content, images, css, etc locally. WebNote will prove useful for anyone who does research on a particular topic or reads a lot.

How It Works

Once extension is installed and you press its icon on the browser toolbar, it pops up with a window (screenshot below) which pre-fills the URL and Title of the page, allows you to select Folder you want to save the page in along with any optional Comments. The extension pre-fills folders field by reading them from the local database which means for the WebNote to work, you need to have WAMP setup locally. Once you press the Save button, the page’s information is saved in the very database. The page itself is saved on hard disk (folder where WebNote CMS will be installed) in MHT format and if you don’t know about MHT format, it is basically a format which saves all resources of a page including images, css in one single page. Internet Explorer supports this format which means saved pages will open in IE.

I won’t go into details of how I created Chrome extension (there are a lot of resources out there) or how pages are saved in MHT format with all their resources in single page or even the small CMS used to manage the pages saved via WebNote because everything can be downloaded (see Installation guide below) and source code can be viewed.

WebNote Screenshot

All the pages saved are accessed via little CMS that I wrote, here are some screenshots.

CMS Screenshots

Notice that from programming perspective, CMS’s code is ugly in that it does not separate PHP and HTML and CMS password is saved with no encryption (since it will run locally). There are some reasons behind that though:

  • I wanted to write application real quick – too lazy to separate php, html logic
  • It was only meant to be for personal use but today I decided to share it
  • It wasn’t meant to be a professional project in which I take all sorts of care

Anyways, it serves the purpose but you can still go ahead and modify the code however you like.


Installing Chrome Extension:

  • Download WebNote Chrome extension and extract contents somewhere
  • In Chrome, type “chrome://extensions/” (without quotes) in address bar, Extensions window will open
  • On the right side of Chrome Extension page, there will be a link “Developer mode“, click on that
  • Now click on the button “Load unpacked extension” and specify path where you extracted the WebNote extension
  • You will notice that a Notepad-like icon will be added to Chrome toolbar that is extension is installed

Installing CMS:

  • Download WebNote CMS and extract it in www/root folder of your WAMP installation folder
  • Open PHPMyAdmin or any other MySQL client of your choice and create a database named “webnote” (without quotes)
  • Import the sql file “webnote.sql” present in WebNote CMS folder in that newly created database
  • In the Webnote CMS folder, go to admin/includes/db.php and edit your database settings accordingly
  • Browse the CMS where you installed it in the browser like “http://localhost/foldername/admin“. You should see Admin login panel
  • Enter “admin” as username and “123123” as password without quotes.

Using WebNote

  • Once logged in, create some folders. You should see Add Folder link to the right of Navigation on the My Folders page.
  • To save a page, click the WebNote icon in the browser toolbar and hit the Save Now button
  • You will see ajax loading image, wait until page is saved. A notification will appear telling you that page is saved.
  • Go back to Admin panel, click on “My Folders” link and then click on the folder you saved the page in.
  • Click on the link title and it will open in Internet Explorer (because MHT is supported by it).

Notes & Tips

  • When you create a folder, it does not create a folder physically on your hard disk. Consider it kind of tag for each page.
  • All files are saved in “mht” folder inside CMS.
  • All other page information including title, folder, url, html is saved in database
  • To save pages, you obviously need to have internet connection to be able to save them locally and read them later
  • You can pre-populate “Comments” field by selecting some text on page and then hitting the WebNote icon in toolbar.

Have fun with your readings and research 🙂