Reputation: 2014
I've been using PhpStorm for a while now and although I'm still learning its features, I will stick with it. I actually work on four machines (a Mac, a PC, a MacBook and my office PC) and I keep my project in a Dropbox location which works well except that my server settings for debugging are set only to my main machine (the Mac) because the config and locations are different - especially between the OSX and Windows. (on the other machines, I test with the Google App Engine)
My question is: can I have my project settings stored in a separate folder to my project files. I have not yet found a way to do this and the online help is not great. If I could, I would keep the project settings on each machine which would allow me to run the project with full server support on each machine.
Upvotes: 4
Views: 1487
Reputation: 18416
Sadly there is no easy means to change the project configuration directory (project/.idea
) location within PHPStorm.
I suggest instead of changing the .idea
location, to use a Git repository with dropbox acting as your server, as opposed to the raw dropbox files.
Alternatively see: PhpStorm - How can I avoid creating the .idea folder?
Along with the ticket https://youtrack.jetbrains.com/issue/WI-343
You can then use .gitignore
to omit the .idea
folder (or others) from your commits between your different environments.
This way you can maintain the history between environments and the ability to revert if an issue occurs. Even share development between other programmers just like on github. One key benefit is being able to make branches of your project for bug fixes, major version updates, and much more. No more needing to copy the entire project somewhere else as a backup, since Git manages it for you!
If you're not familiar with Git, it is fairly intuitive to use with PHPStorm and there are tons of help topics, guides and answered question online when using it from the console for features that PHPStorm doesn't provide a GUI for. See the Git documentation from PHPStorm
First off you'll need to install Git. You don't need anything fancy like GUI since PHPStorm will handle the majority of it and it can be installed on any OS. I also suggest moving your project outside of the dropbox directory and into a local directory, this way the files won't overlap from the repo and dropbox.
Next you need to create a bare Git repository in your dropbox synchronized directory on your computer. This just means that a working copy is not checked out, protecting the files from outside changes. For the purposes of explanation I use SkyDrive in place of dropbox on my Windows System.
In your console:
$ mkdir D:\SkyDrive\repos
$ cd D:\SkyDrive\repos
$ git init --bare myproject.git
Next you need to initialize Git with your PHPStorm project.
This will create a .git directory inside your project in order to store that computer's history.
Now create a .gitignore
file in the root directory of your project.
Edit the .gitignore
file and add the following line.
Add the paths of any other files you do not want to share between the different environments, such as application cache, session directory, binary files, composer.phar libraries, and so on.
Next add the files as being versioned by Git
You'll notice that the file names changed to Green text in PHPStorm, indicating that they are new files. Any files with Blue text indicate they have been modified. Red text indicates they have not been added as versioned to Git (aka unstaged). Grey text file names mean they are ignored, and normal theme colored text mean they have been committed.
One key point about Git here is that it does not track empty directories. Such as ignoring a directory of files, like we did by ignoring .idea
. and need the empty directory to be created in other environments, such as /var/cache
, create another .gitignore
file in that directory and add the lines.
*
!.gitignore
This will ignore all files within that directory, except for the .gitignore
file and the directory itself.
Now we need to commit
the current changes to Git and add a short message of what you did for easy reference later when looking through your history.
Almost done, now you need to push
your changes to the ~/SkyDrive/repos/myproject.git
repository also known as the remote origin/master
(by default).
Now your files and its branches are managed by Git and will be available to the other computers anytime you push
your changes to the remote origin
repository.
Last step is to checkout
the project in your other computer.
Open PHPStorm, and click Check out from Version Control, select Git, fill in the repository location and where you would like to store the files on the local environment (outside of dropbox) and click Clone.
When prompted click Ok to open the project and you're done, make changes, commit
them, push
them to the remote origin
, then pull
the changes from another system.
Configure your project's settings how you like (or export them from another installation).
Don't forget that you need to
commit
andpush
your changes to make them available for apull
from the other systems.
A special consideration - be sure that dropbox has finished Syncing before pulling changes from another system, otherwise it may cause corruption of the repo.
If this occurs you can delete the remote repo in the dropbox directory, recreate a new repo using git init --bare repo
in the same location as described previously, and push the latest changes to it.
Upvotes: 4