To share your code, you can create gists right from PhpStorm. A gist can contain a code snippet, an entire file, several files, and even folders.
You can also use gists to save and share console output during running, debugging, testing, etc.
On this page:
Enabling creation of gists
Saving code in a gist
Select the code to be shared by doing one of the following:
- To have a piece of code from a single file shared, open the file in the editor and select the required code snippet. If no selection is made, the gist will contain the entire file.
- To have the code from a file shared, select the file name in the Project view.
- To create a gist from a folder, select the folder in the Project view.
- To create a gist from several files or folders, select them in the Project view.
- On the context menu of the selection, choose Create gist.
- In the Create Gist dialog box, that opens, provide a brief description of the gist to be created.
Configure the gist's visibility.
- By default, the new gist will be public, that is, visible for all registered users with your login displayed as owner. To accept this default behaviour, just click OK.
- To create a private gist that will be available for you only, select the Private check box.
- To make the gist available for all registered users without displaying your login, select the Anonymous check box.
Specify whether you want PhpStorm to open the new gist in a browser or not:
- To have the gist opened in the default PhpStorm browser so you can edit it right now, select the Open in browser check box. When you click OK, the https://gist.github.com/ page, that opens, shows the new gist with the selection or the entire contents of the current file. By default, the gist is named after the file the gist originates from. To update the code snippet, if necessary, click Edit.
- If you do not want to open the gist right now, clear the Open in browser check box. PhpStorm displays the URL address of the gist so you you can access it later.
Saving console output in a gist
- During a run, debug, or test session, or when running commands in the command line mode, switch to the relevant tool window or tab that presents the output of the application or command.
- Click the right mouse button anywhere in the tab and choose Create Gist on the context menu.
- In the Create Gist dialog box, that opens, provide a brief description of the gist to be created and configure the gist's visibility.
- Specify whether you want PhpStorm to open the new gist in a browser or not.