Using PHPStorm IDE: Difference between revisions

From Littledamien Wiki
Jump to navigation Jump to search
 
Line 144: Line 144:


== Notes ==
== Notes ==
=== See also ===
* [[Working With PHPStom IDE]]
=== References ===
<references />
<references />

Latest revision as of 17:02, 5 February 2017


Overview[edit]

Notes about using the PHPStorm IDE, which has some features that are not entirely intuitive to use.

Comparison to NetBeans[edit]

So far, every feature that I liked about NetBeans is available in PHPStorm. PHPStorm's performance seems to be much better than NetBeans.

Working with a local network repository[edit]

One of the reasons for NetBeans' slow performance might have been that I was accessing the files directly off the local network share.

While it's possible to do this also with PHPStorm, there are some useful features that are unavailable, plus the performance for searches, etc. is much slower.

Create a new project using existing files on a network volume[edit]

First, mount the network volume:

$ mount -t smbfs //user:password@server/share_name path/to/mount

In PhpStorm:

  • File > New Project from Existing Files...
  • Select scenario: Web server is on remote host, files are accessible via network share or mounted drive.
  • Specify Local Path
    • Enter desired project name & path to local project.
    • Deployment options: Default
  • Specify Remove Server
    • Select Add new remote server if necessary.
    • Don't check HTTP connection to server: checked
  • (Optional) Add Remote Server
    • Name: pick a name
    • Upload/download project files/Folder: Enter mount point of remote server, e.g. /users/damien/remote/myshare
    • Web server root URL: Enter local URL for the project on the network share, e.g. http://myproject.dbarchowsky.com
    • Don't check HTTP connection to server: checked
    • Note that the settings for the existing remote servers can be edited via PhpStorm > Preferences > Build, Execution, Deployment > Deployment
  • Choose Remote Path
    • Highlight the folder representing the project root, then click Project Root button above the directory tree.
    • Also optionally select individual folders and mark them to be excluded from indexing, e.g. .sass-cache, node_modules, etc.
  • Specify Web Path
    • Enter a path relative to the project root where the web root is located.
  • After clicking the Next button at this point, PhpStorm will be begin downloading files from the network share to the local project directory and the PhpStorm project will be created.

TODO: Document how to prevent vendor files from being downloaded from the network share when the project is created.

SQL[edit]

Executing SQL from .sql files[edit]

  • Either select the .sql file in the Project pane, or open it in the Editor pane.
  • right click' > Run [filename.sql] (Ctrl+Shift+F10)

Viewing data retrieved with a SELECT statement[edit]

  • Open the .sql file in the Editor pane
  • Alt+Enter > Run Query in Console
  • The results will be displayed in a tab in the Database Console pane.[1]

Deployment[edit]

Syncing using Git and GitHub[edit]

  • Create a repository on GitHub
  • Create a local git repo.
  • Create a remote pointing to the GitHub repo.
  • Before starting work, pull from the GitHub repo.
  • Create a new branch.
  • Make changes to code.
  • Commit changes.
  • Switch to the master branch.
  • Sync master to the branch with the new commit.
  • Push to GitHub.

Creating a new deployment target[edit]

This can be done multiple ways.

Through the Tools menu[edit]

  • Tools > Deployment > Configuration
  • Click the + button
    • Connection tab
      • Type: Local or mounted folder
      • Folder: (Navigate to remote folder. It must be mounted as a local drive.)
    • Mappings tab
      • Make sure that at least a slash is entered into the Deployment Path field.
    • Excluded Paths tab
      • Enter any local or remote paths that should be ignored as part of the sync.

Through the project settings[edit]

  • File > Default Settings (Ctrl+,)
  • Left column > Build, Execution, Deployment > Deployment
  • This opens up the same dialog described above.

Accessing remote servers[edit]

If a remote server has been configured, but is not showing up in the list of servers for syncing or uploading, the cause is most likely that mappings have not been created between the project and the remote server.

  • Tools > Deployment > Configuration
  • Select a remote server in the list
  • Mappings tab
    • Confirm that there is a value entered for Deployment path on server
    • Enter "\" to use the root directory on the server.

Syncing with a remote server[edit]

In the Project pane' click on the project's root node.

With the project root node selected, either right click > Sync with deployed to… > Choose server to sync with —or— Tools > Deployment > Sync with deployed to…

This will open a Diff Between dialog that lists all the files that differ between the local project and the remote repository.

Arrows will indicate if the sync operation will upload or download the newer version of a file. Right click on the arrow to change the status, e.g. a red X for Set Delete or a blank space for Set Do Nothing.

The pane in the lower half of the dialog displays the differences between the files.

After reviewing the files that differ, either click the single arrow to sync a single file, or the double arrows to sync all the files in the list.

Excluding files and directories from sync operations[edit]

Remote host[edit]
  • View > Tool Windows > Remote Host > select host from dropdown
  • right click on files or directories to exclude > Exclude Path
Local project, for all remote hosts[edit]
  • Project pane > select a file or directory > right click > Mark Directory As > Excluded
Local project, for a specific remote host[edit]
  • File > Settings > Build, Execution, Deployment > Deployment > select remote host from list > Excluded Paths tab
  • Add local path button
    • Click the button to the right of the path field.
    • Select the file or directory to exclude.
    • Hit the Enter key

Notes[edit]

See also[edit]

References[edit]

  1. Running SQL scripts - JetBrains