Uncategorized

Configure PHPStorm to debug Drupal 8

Devel module provides dsm() and dpm() functions to output variables on the page for debugging Drupal. But if the problem is more complicated, then that’s not sufficient. You can simplify debugging tremendously if you stop code execution using breakpoints and then execute the application one step at a time. All IDEs that support PHP debugging, such as Eclipse, Netbeans, PHPStorm, etc., provide the functionality to put breakpoints in the code. But it requires quite a bit of configuration to make it work. In this post, you will learn how to configure PHPStorm 9 to debug Drupal 8. By the end of this article, you will be able to stop code execution in PHPStorm by putting a breakpoint.

 

It is assumed that you have already installed Drupal 8 on your local system and you are able to open the site in your browser. In my case, the Drupal 8 site is available at http://localhost/drupal8.

1) Set up a project for Drupal 8 in PHPStorm

Open PHPStorm and select “Create New Project from Existing Files”.

In the next screen, select “Web server is installed locally, source files are located under its document root.” and press “Next”.

In the next step, PHPStorm will ask you to select the root folder of the Drupal 8 project. In my case, I have installed drupal in /Users/neemehta/Sites/drupal8 folder. So I will select this folder and then click on “Project Root” at the top. Click on “Next”.

Now PHPStorm will ask you whether you want to use an existing server or a new server. If you have already used PHPStorm with other Drupal projects before, you will have an existing server. If this is the first time you are using PHPStorm, then you will need to add a new server. In this post, I’ll show you how to add a new server. Click on “Add new local server” and then press “Next”.

Fill in the server details. Enter name as “localhost” and Web server root URL as “http://localhost“. Click on “Open” and you will see http://localhost in your broswer. It is possible that your Apache server may deny you access to http://localhost. In that case, make sure that you check “Don’t check HTTP connection to server” checkbox before pressing “Next” otherwise PHPStorm will show you an error.

In the next step, you need to specify the web path where your Drupal 8 site will be accessible. In my case, it is accessible at http://localhost/drupal8 so I will enter Web path as “drupal8”. An easy way to enter a value in this field is to make sure that the Project URL below the textfield points to the Drupal 8 site. Check “Review PHP settings” checkbox and press “Next”.

Make sure that PHPStorm is using the right version of PHP. If you have multiple versions of PHP installed on your system, then depending on the PATH environment variable, it is possible that PHPStorm may be using another version. If that is the case, make sure that the version of PHP that you want to use for Drupal 8, PHP 5.5 or 5.6, appears in the PATH variable before the other versions. Once the PHP version is correct, click on “Finish”.

PHPStorm should now create a new project for your Drupal 8 site.

 

View More 1
View More 2
View More 3
View More 4
View More 5
View More 6
View More 7
View More 8
View More 9
View More 10
View More 11
View More 12
View More 13
View More 14
View More 15
View More 16
View More 17
View More 18
View More 19
View More 20
View More 21
View More 22
View More 23
View More 24
View More 25
View More 26
View More 27
View More 28
View More 29
View More 30
View More 31
View More 32
View More 33
View More 34
View More 35
View More 36
View More 37
View More 38
View More 39
View More 40
View More 41
View More 42
View More 43
View More 44
View More 45
View More 46
View More 47
View More 48
View More 49
View More 50
View More 51
View More 52
View More 53
View More 54
View More 55
View More 56
View More 57
View More 58
View More 59
View More 60
View More 61
View More 62
View More 63
View More 64
View More 65
View More 66
View More 67
View More 68
View More 69
View More 70
View More 71
View More 72
View More 73
View More 74
View More 75
View More 76
View More 77
View More 78
View More 79
View More 80
View More 81
View More 82
View More 83
View More 84
View More 85
View More 86
View More 87
View More 88
View More 89
View More 90
View More 91
View More 92
View More 93
View More 94
View More 95
View More 96
View More 97
View More 98
View More 99
View More 100
View More 101
View More 102
View More 103
View More 104
View More 105
View More 106
View More 107
View More 108
View More 109
View More 110
View More 111
View More 112
View More 113
View More 114
View More 115
View More 116
View More 117
View More 118
View More 119
View More 120
View More 121
View More 122
View More 123
View More 124
View More 125
View More 126
View More 127
View More 128
View More 129
View More 130
View More 131
View More 132
View More 133
View More 134
View More 135
View More 136
View More 137
View More 138
View More 139
View More 140
View More 141
View More 142
View More 143
View More 144
View More 145
View More 146
View More 147
View More 148
View More 149
View More 150
View More 151
View More 152
View More 153
View More 154
View More 155
View More 156
View More 157
View More 158
View More 159
View More 160
View More 161
View More 162
View More 163
View More 164
View More 165
View More 166
View More 167
View More 168
View More 169
View More 170
View More 171
View More 172
View More 173
View More 174
View More 175
View More 176
View More 177
View More 178
View More 179
View More 180
View More 181
View More 182
View More 183
View More 184
View More 185
View More 186
View More 187
View More 188
View More 189
View More 190
View More 191
View More 192
View More 193
View More 194
View More 195
View More 196
View More 197
View More 198
View More 199
View More 200
View More 201
View More 202
View More 203
View More 204
View More 205
View More 206
View More 207
View More 208
View More 209
View More 210
View More 211
View More 212
View More 213
View More 214
View More 215
View More 216
View More 217
View More 218
View More 219
View More 220
View More 221
View More 222
View More 223
View More 224
View More 225
View More 226
View More 227
View More 228
View More 229
View More 230
View More 231
View More 232
View More 233
View More 234
View More 235
View More 236
View More 237
View More 238
View More 239
View More 240
View More 241
View More 242
View More 243
View More 244
View More 245
View More 246
View More 247
View More 248
View More 249
View More 250
View More 251
View More 252
View More 253
View More 254
View More 255
View More 256
View More 257
View More 258
View More 259
View More 260
View More 261
View More 262
View More 263
View More 264
View More 265
View More 266
View More 267
View More 268
View More 269
View More 270
View More 271
View More 272
View More 273
View More 274
View More 275
View More 276
View More 277
View More 278
View More 279
View More 280
View More 281
View More 282
View More 283
View More 284
View More 285
View More 286
View More 287
View More 288
View More 289
View More 290
View More 291
View More 292
View More 293
View More 294
View More 295
View More 296
View More 297
View More 298
View More 299
View More 300
View More 301
View More 302
View More 303
View More 304
View More 305
View More 306
View More 307
View More 308
View More 309
View More 310
View More 311
View More 312
View More 313
View More 314
View More 315
View More 316
View More 317
View More 318
View More 319
View More 320
View More 321
View More 322
View More 323
View More 324
View More 325
View More 326
View More 327
View More 328
View More 329
View More 330
View More 331
View More 332
View More 333
View More 334
View More 335
View More 336
View More 337
View More 338
View More 339
View More 340
View More 341
View More 342
View More 343
View More 344
View More 345
View More 346
View More 347
View More 348
View More 349
View More 350
View More 351
View More 352
View More 353
View More 354
View More 355
View More 356
View More 357
View More 358
View More 359
View More 360
View More 361
View More 362
View More 363
View More 364
View More 365
View More 366
View More 367
View More 368
View More 369
View More 370
View More 371
View More 372
View More 373
View More 374
View More 375
View More 376
View More 377
View More 378
View More 379
View More 380
View More 381
View More 382
View More 383
View More 384
View More 385
View More 386
View More 387
View More 388
View More 389
View More 390
View More 391
View More 392
View More 393
View More 394
View More 395
View More 396
View More 397
View More 398
View More 399
View More 400
View More 401
View More 402
View More 403
View More 404
View More 405
View More 406
View More 407
View More 408
View More 409
View More 410
View More 411
View More 412
View More 413
View More 414
View More 415
View More 416
View More 417
View More 418
View More 419
View More 420
View More 421
View More 422
View More 423
View More 424
View More 425
View More 426
View More 427
View More 428
View More 429
View More 430
View More 431
View More 432
View More 433
View More 434
View More 435
View More 436
View More 437
View More 438
View More 439
View More 440
View More 441
View More 442
View More 443
View More 444
View More 445
View More 446
View More 447
View More 448
View More 449
View More 450
View More 451
View More 452
View More 453
View More 454
View More 455
View More 456
View More 457
View More 458
View More 459
View More 460
View More 461
View More 462
View More 463
View More 464
View More 465
View More 466
View More 467
View More 468
View More 469
View More 470
View More 471
View More 472
View More 473
View More 474
View More 475
View More 476
View More 477
View More 478
View More 479
View More 480
View More 481
View More 482
View More 483
View More 484
View More 485
View More 486
View More 487
View More 488
View More 489
View More 490
View More 491
View More 492
View More 493
View More 494
View More 495
View More 496
View More 497
View More 498
View More 499
View More 500

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button