Git Product home page Git Product logo

phpstorm-workshop's Introduction

official JetBrains project Latest Stable Version Total Downloads License

PhpStorm Workshop

In these materials, you'll learn about many of the features and productivity tools available in PhpStorm. Examples are navigation, editing, inspections, live templates, refactoring, tools like Composer and the HTTP client, and many more. It's virtually impossible to cover every option and feature in PhpStorm, but we're providing a number of practical exercises on how we can do our daily work as PHP developers.

We'll also cover a vast amount of keyboard shortcuts to make working with PhpStorm more efficient. Other IntelliJ-based IDE's use the same keyboard shortcuts, so if you know how to work with PhpStorm, you'll know how to work with WebStorm, RubyMine, PyCharm, IntelliJ IDEA and more. A cheat sheet is available online and is also included in the workshop download.

This workshop is self-paced, meaning you can work your way through exercises on your own, whenever and wherever you want. Exercises come as a PhpStorm project in which every file is a new exercise that may contain code and tips to get things done.

Prerequisites

  • Docker for Mac, Docker for Windows or Docker (Linux) 1.13+. See Docker documentation for installation instructions for your operating system.
  • PhpStorm 2016.3+

Getting the Project

There are several ways to get started with the PhpStorm workshop materials:

  • Create a new PhpStorm Workshop Project in PhpStorm

  • Create a new project with Composer. Note that you can also create a new project in PhpStorm: use the Composer project type and search for "jetbrains/phpstorm-workshop"

    php composer.phar create-project jetbrains/phpstorm-workshop -s dev

  • Clone the project from GitHub

    git clone https://github.com/JetBrains/phpstorm-workshop.git

    git checkout docker

  • Download the ZIP

    wget https://github.com/JetBrains/phpstorm-workshop/archive/docker.zip

Getting Started

Most exercises not related to the code editor require having Docker containers running.

Before you start:

  1. Open Settings/Preferences | Build, Execution, Deployment | Docker and select how to connect to the Docker daemon:

    • Windows:

      • Select TCP socket.
      • Set Engine API URL to tcp://localhost:2375.
      • Leave the Certificates folder field empty.

      Make sure to enable Expose daemon on tcp://localhost:2375 without TLS in the General section of Docker for Windows settings.

    • macOS:

      • Select Docker for Mac
    • Linux:

      • Select Unix socket
  2. Update XDEBUG_CONFIG variable in docker-compose.yml with the value depending on your operating system. This is necessary for Web Debugging.

    • Windows/macOS: use host.docker.internal, which will automatically resolve to the internal address of the host Docker is running on.
    • Linux: execute hostname in Terminal and use the returned value.
  3. Uncomment an appropriate line for sftp service in the same docker-compose.yml. This is necessary for Deployment to work correctly.

  4. In the same docker-compose.yml, click the Run icon next to services: in the editor gutter to start all required Docker containers. Alternatively, you can open the built-in PhpStorm terminal from View | Tool Windows | Terminal and execute the docker-compose up command.

There are some things to know about the project:

  • The project can be opened as is in PhpStorm. We've included configurations for PHP Remote Interpreter, Database, Deployment Server, PHP Web Debug, PHPUnit and Behat.
  • All numbered folders contain exercises that you can work on. Simply open the numbered files one by one and follow the comments in the file. Most exercises are self-contained, others build on previous exercises.
  • Some of the exercises (like this one) are in Markdown format. You can read these files easier by toggling View to Show Preview Only in the top-right corner.
  • The PhpStorm Reference Card.pdf is the PhpStorm keymap. The latest version can always be found on the PhpStorm website.

Open Source and Contribution

The workshop is Open Source, licensed under the Apache 2 license. If you would like to contribute to the workshop materials, please feel free to fork the repo and send us a pull request. Or if you have a comment, question, or suggestion for improvements, please raise an issue.

phpstorm-workshop's People

Contributors

andrey-sokolov avatar dmitrytronin avatar emrzv avatar entioentio avatar geeh avatar isfedorov avatar maartenba avatar maxal avatar mikemclin avatar mikhailvink avatar muffinpaws avatar nicklasmoeller avatar prik avatar relaxnow avatar saracubillas avatar tfrommen avatar tugrulcan avatar wbars avatar zeitgen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

phpstorm-workshop's Issues

Navigation / Navigate to class - "non-project" unclear

In 1.3_Navigate_to_class.md it says

Check the Include non-project classes check box and open the ArrayObject (PHP SPL library) class. By default PhpStorm only searches classes inside your project, not your dependencies in the vendor folder.

Command+O opens a search window on the "Classes" tab. There is no "include non-project classes" check box that I could find.

After some travels through the Google and randomly trying things in the app, i found that if you choose the "All" tab, you get a checkbox for "Include non-project items", and the setting there seems to stick when you go back to the "Classes" tab.

I guess the app is moving faster than the workshop pages, but I'm not sure of a good way to explain all of that.

This is in PhpStorm 2021.1.3 Build PS-211.7442.50 from 2 June 2021, on MacOS

02_Editing lesson 1.3: Adding `/** @var $people Person[] */` does not make a difference

Adding /** @var $people Person[] */ does not seem to make a difference when I type $person->.
What I see in both cases (with and without the 'comment'):
I have to type > as well, while in previous cases this was automatically added.
Then I see a popup dialog with getAge, getName, setAge, setName.
So, in both cases I see completion (at least in the way I understand it).

F1 also works in both cases.

Search Everywhere: type _name should be removed

Lesson 1.6
Use recent files
Navigate to the $_name protected variable in Customer.php (type _name).

If you type this, nothing will be found, which is a bug, or good to know...
I think the idea is that you don't have to type anything, and you will see Customer.php among the recent files.

OSX Keymappings incorrect in slides

Keymapping for a number of features is incorrect in the slides when using OSX. I'm using the OSX 10.5+ keymap, on PHPStorm 7.1.3.

Perhaps it would be better for the Materials to use a separate version of the slides for both Mac and Linux/Windows ?

Next Tab
Slide: Alt+Command Left / Right
Actually: Cmd+Shift + Square brackets ([ or ]) AND Ctrl + Left / Right

Project Tool Window
Slide: Alt + 1
Actually: Cmd + 1

Navigate to Declaration
No mention is made of the Mac version
Slide: Ctrl + Click
Actually: Cmd + Click

After these initial pages, the problems seem to become less frequent. Will create additional issues if more are found.

PhpStorm and Docker - Unable to configure the Remote PHP interpreter (Failed to parse script validation output)

I'm using Docker composer with a PHP. When trying to set the interpreter I choose Docker compose and connecting with existing container and then it fails with the error "Failed to parse script validation output".

If I execute php -v inside the container everything seems fine,

What is the expected result? An installed php version should be shown

What happens instead? Failed to parse validation script output message and PHP version: not installed label

It's working fine with docker-compose run lifecycle

PS:
OS : RHEL 8.8
PhpStorm 2023.1.2

Docker version 24.0.2, build cb74dfc

Settings > Build, Execution, Deployment > Docker > Tools and checking the box "Use Compose V2" didn't work for me.

Getting below error in ide.log

2023-06-15 11:30:07,860 [1825374] FINE - #c.j.p.c.p.PhpInfoUtil - Parsing validation output: Could not open input file: /opt/.phpstorm_helpers/phpinfo.php

2023-06-15 11:30:07,861 [1825375] INFO - STDERR - [Fatal Error] :1:1: Content is not allowed in prolog.

2023-06-15 11:30:07,861 [1825375] WARN - #c.j.p.c.p.PhpInfoUtil - Failed to parse validation output: Could not open input file: /opt/.phpstorm_helpers/phpinfo.php

2023-06-15 11:30:07,862 [1825376] FINE - #c.j.p.c.p.PhpInfoUtil -

com.intellij.execution.ExecutionException: Failed to parse validation script output

image

03 Inspections 01 Highlights: 5. Dead Code

Nothing is highlighted or underlined, or what have you.

No other instruction than that it is dead code. Something should be visible, isn't it?

// 5. Dead code (unused variable).
public function deadCodeFunction1()
{
    $variable = true;
}

XDEBUG_CONFIG for macOS has extra comma

In docker-compose.yml the alternative XDEBUG_CONFIG is missleading.
Multiple configs are separated by space.
So with the proposed
XDEBUG_CONFIG: remote_host=host.docker.internal, remote_port=9001
XDebug tries to make a connection to http://host.docker.internal,:9001 and fails.

Working config is:
XDEBUG_CONFIG: remote_host=host.docker.internal remote_port=9001

By the way: Validate Debugger Configuration on Web Server shows all green check marks even with wrong config.

08_Testing bug

Hello,

In 08_Testing/02_Runing_tests is written:
// From the Settings | Languages & Frameworks | PHP | Test Frameworks | PHPUnit,
// set workshop\08_Testing\Code\Bootstrap.php as the default bootstrap file.

I have tried different configuration and for me only works
// set /opt/project/workshop/08_Testing/Code/Bootstrap.php as the default bootstrap file or
// set Code/Bootstrap.php as the default bootstrap file
otherwise Boostrap.php file could not be found...
selection_130

02 Editing\08 Multiple Selections

// 2. Place the cursor right after the first *. Press and hold Alt+Shift and use the mouse to select
// the locations where a cursor is desired, right after every *.

This needs to be changed to Alt+Click. I am relatively new to PhpStorm and I was trying my best to get this to work until I googled the answer. It had me so frustrated, lol.

Great program and workshop materials!

Behat tests

Hello,

I think it would be nice to have a behat testing documentation/solution.

Thank you for your hard work!

They can't understand how to navigate to $_name.

My phpstorm version: PS-139.1069(8.0.3)
in File:

  1. Navigate to symbol.
    Navigate to the $_name protected variable in Customer.php.

I use "_name" it works well, So please point how to navigate to the $_name. Thank you

Navigate to Symbol: JavaScript filter is not called JavaScript

Lesson 1.5:
Use filters
Filter to only search in JavaScript files and find the celebrateBirthday() function in the Customer.js file.

The filter is actually called ECMAScript 6

That was not intuitive, so it should be stated that this filter should be used.
It's good to know this 'subtle' difference exists...

Outdated Composer insttuctions

Instructions for Composer Init at workshop/12_Tools/02_Composer.md seems to be outdated: one can't Initialize Composer via context menu.
We should correct instructions accordingly

PHPCS executable not found

  • OSX 10.13.3
  • PhpStorm 17.3.2
  • workshop/03_Inspections/06_PHPMD_PHPCS.md
  • Docker branch

I was following all of the tutorials in sequence from the beginning, and ran into my first issue with this part.

  1. Click "Create" application level copy of this deployment server and then click "OK"

Step 1 at the top of this tutorial had no issues. Step 2 could not be completed, I could not find "Create" anywhere, and after re-trying and snooping around, I still could not figure out this step.

PHPCS configuration:

  1. Click [...] and and make sure that path for PHPCS is phpcs. Validate installation.

When clicking "Validate" I received the error Cannot run program "phpcs": error=2, No such file or directory

mysql database missing

I follow the steps of the file:
workshop/10_Database/01_Connecting_to_a_database.md
But I cannot see the jetbrains database after that. Is that part working?

Improve Behat workshop

The main idea of the workshop is to provide the seamless experience with the new features, meaning (no configuration, no terminal usage and so on). We provide the Vagrant box that has everything needed (PHP, Behat, etc.). You should avoid using anything besides that.

The fix should avoid behat --init, use Vagrant interpreter instead, and progress via MD file (instead of PHP comments)

Since configuration will be different for Docker there should be a fix for Docker branch as well.

docker-compose up gives "phpstormworkshop_mysql_1 exited with code 1"

Running on 10.12.3 with Docker Machine and it doesn't seem to be able to get it all the way up...

docker-compose up
Starting phpstormworkshop_sftp_1
Starting phpstormworkshop_debug_1
Creating phpstormworkshop_mysql_1
Attaching to phpstormworkshop_sftp_1, phpstormworkshop_debug_1, phpstormworkshop_mysql_1
debug_1  | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.24.0.3. Set the 'ServerName' directive globally to suppress this message
debug_1  | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.24.0.3. Set the 'ServerName' directive globally to suppress this message
debug_1  | [Fri Mar 31 10:51:39.148411 2017] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.10 (Debian) PHP/7.1.2 configured -- resuming normal operations
mysql_1  | Initializing database
phpstormworkshop_mysql_1 exited with code 1

03 Inspections: 08 Run Inspections: Where is the 'Inspection profile dropdown'?

Create a custom Inspection profile in which only a few inspections are enabled.
HINT: Use the [...] next to the Inspection profile dropdown to enable or disable inspections in the selected profile.

I've searched in Settings, looked at the Code menu, looked at the interface...
Where is the 'Inspection profile dropdown'?

Poor developer experience when PhpStorm doesn't work out of the box

I'm on macOS Sonoma, using the latest Docker Desktop for Mac, and the latest version of PhpStorm.

I followed the guide to install the Workshop from within PhpStorm:

Screenshot 2023-10-09 at 10 02 53 PM

As instructed, I edited the docker-compose.yml to uncomment:

XDEBUG_CONFIG: remote_host=host.docker.internal

and

- /tmp:/home/jetbrains/upload

I ran the project as instructed, but this fails on an ARM processor Mac as the images are all Intel-based.

I then tried on an Intel Mac (again, latest Docker & PhpStorm) and I am at least able to build the project and it appears to run.

The docker-compose.yml appears to suggest I should be able to reach the project on port 8081 but this also fails:

Screenshot 2023-10-09 at 4 47 43 PM

The logs say:

[Mon Oct 09 23:47:24.636827 2023] [autoindex:error] [pid 18] [client 192.168.65.1:30717] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.php,index.html) found, and server-generated directory index forbidden by Options directive
2023-10-09T23:47:24.637237955Z 192.168.65.1 - - [09/Oct/2023:23:47:24 +0000] "GET / HTTP/1.1" 403 493 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/118.0"

Later in the Debug your application section of the guide:

Screenshot 2023-10-09 at 7 43 55 PM

This is incorrect. There is no such interpreter automatically configured (that would require PhpStorm to create an .idea folder with the interpreter already configured when generating the Workshop, right?):

Screenshot 2023-10-09 at 5 52 47 PM

I then attempt to create an interpreter, although the guide is no help at this point since it assumes it was automatically created:

Screenshot 2023-10-09 at 5 53 19 PM Screenshot 2023-10-09 at 5 53 51 PM

Creating an interpreter which points at the php in the docker container is not enough. It appears a Run configuration needs to be created as well, and requires pointing the Run configuration at the exact same docker-compose.yml used when creating the interpreter:

Screenshot 2023-10-09 at 5 55 20 PM

After attempting to run the docker compose project, I was prompted with this:

Screenshot 2023-10-09 at 4 46 49 PM

There are no options for telling PhpStorm to get the phpinfo() from the interpreter I've already configured. Given that I can't actually run this project, I can't copy and paste it either.

I stumbled upon this tutorial project after wasting time trying to get PhpStorm & xdebug working in a docker compose environment. The PhpStorm documentation is very fragmented and doesn't walk someone through a full working example for a docker compose-based setup. It's a shame that this official tutorial doesn't work either.

What is the right way to spin up a docker compose environment, configure PhpStorm to run the docker compose containers, and connect to xdebug for debugging?

Incorrect OSX keyboard shortcut in `Project Tool Window.txt`

In the first tutorial...

phpstorm-workshop / 01 - Navigation / 01 - Navigate to something you know / 1.1. Project Tool Window.txt

It says the keyboard shortcut for opening the Project Window is Alt+1 (Windows/Linux/Mac OS X)

On Mac OSX, it is suppose to be Command+1

Wrong shortcut

I use phpstorm 2022.3

In chapter 06_Todo folder, in file 01_Todo.php, in line 5, says that Alt+6 (Windows/Linux) is the shortcut for the Todo Tool Window

However, Alt + 6 opens the Problems Tool Window.

03 Inspections 01 Highlights: Suppress for statement?

I don't understand what is meant with 'Suppress for statement'.

I can choose 'Typo rename to...', but there is no 'Suppress for statement'

// 7. A warning highlight is shown on the misspelled variable "$mispelled".
//    Suppress the inspection for this statement only using Show Intention Actions |  Typo rename to...
//         | Suppress for statement

It's a typo, or it is not clear what is supposed to happen, or it is not clear what I am supposed to do.

can not run docker deployment

Hi,I have docker installed correctly,but when I add run configuration in phpstorm and run,the following message raising
Deploy log
Deploying 'Compose: docker-compose.yml'...
Failed to deploy 'Compose: docker-compose.yml': Cannot run program "docker-compose" (in directory "D:\project\docker-example"): CreateProcess error=2, 系统找不到指定的文件。
image

docker-compose relative file path. Error: Can't read compose file project/./v2/../../v2/docker-compose.yml

I have docker-compose.yml file in the root of my project and I can run it directly from terminal with docker-compose up
But when I try to add a docker debug configuration from docker-compose file, I cannot set proper absolute path.
When I add path do docker-compose.yml, everything is fine.

image

But when I press OK, the IDE replace it with a relative path based on my project dir, like this:

image

And obviously this configuration cannot run with the following error:

Deploying 'Compose: v2'...
Failed to deploy 'Compose: v2': Can't read compose file at /path/to/my/project/./v2/../../v2/docker-compose.yml

How can I set the absolute path, or make this relative path works in IDE?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.