Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Debug interactively PHP BLT #7

Debug interactively PHP BLT #7

Sota Sugiura

May 22, 2017
Tweet

More Decks by Sota Sugiura

Other Decks in Technology

Transcript

  1. Using REPL (php -a) • Easy to use • Can

    load files • Good integration with CLI
  2. Is it the best way? • Bother to require autoloader

    • Reset state every time • Not good for many autoloader files…
  3. Rich REPL • Auto complete (with Tab key) • Useful

    commands • history, documentation, show properties • Rich UI
  4. <?php // Automatically autoload Composer dependencies if (is_file(getcwd() . '/vendor/autoload.php'))

    { require_once(getcwd() . '/vendor/autoload.php'); } Load composer automatically
  5. <?php // Use local config, if available if (is_file(getcwd() .

    '/.psysh.php')) { return require(getcwd() . '/.psysh.php'); } // Fall back to global config return [ 'startupMessage' => '<info>Using global config</info>', 'commands' => [ new \Psy\Command\ParseCommand, ], ]; Load local config
  6. <?php $default_includes = []; // Automatically autoload Composer dependencies if

    (is_file(getcwd() . '/vendor/autoload.php')) { $default_includes[] = getcwd() . '/vendor/autoload.php'); } if (array_pop(explode('/', getcwd())) === '') { $default_includes[] = getcwd() . 'lecacy_autoloader.php'; } return [ 'defaultIncludes' = $default_includes, ]; Legacy project? No problem☺