- This is an WebApp example for M07 DWES.
- db: All structured data files: databases, .csv files, etc.
- public: All static content: img, css, js, etc.
- src: The main codebase that generates the dynamic content.
- lib: Libraries and third-party code.
- Start reading src/rewriter.php
- Copy the whole directory containing this file wherever you want.
- php -S 0.0.0.0:8080 -t public/ src/rewriter.php
- Configure URL Rewriting.
- Point the web server to execute router.php on every execution.
-
Open debug panel to the left.
-
Generate and open .vscode/launch.json
-
Append the following code to the "configurations" array:
{ "name": "Launch Rewriter", "type": "php", "request": "launch", "runtimeArgs": [ "-dxdebug.mode=debug", "-dxdebug.start_with_request=yes", "-S", "localhost:8080", "-t", "${fileDirname}/../public", "${file}" ], "program": "", "cwd": "${workspaceRoot}", "port": 9003, "serverReadyAction": { "pattern": "Development Server \\(http://localhost:([0-9]+)\\) started", "uriFormat": "http://localhost:%s", "action": "openExternally" } }
-
Save .vscode/launch.json
-
Open again the VSCode debug panel in the left. At the top of the panel there is a list of four options.
- Launch currently open script: Runs a script in a terminal.
- Launch Rewriter: Launches a webapp in PHP's development server. Choose "Launch Rewriter", but don't press the "Play" button.
-
Open the file src/rewriter.php and press F5.
-
The debugger will start. You can add breakpoints and leave the debugger running while you change code. Refresh the browser to see changes.
- Press F12 to open the Developer Tools.
- Click on the 'Network' Tab.
- Check 'Disable Cache'. (Very important!)