PHP code example of groundwork / groundwork-hacklang

1. Go to this page and download the library: Download groundwork/groundwork-hacklang library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

groundwork / groundwork-hacklang example snippets



$router->register('articles/:id', function($ioc) {
    $request = $ioc->get('request');
	$response = $ioc->get('response');
	if ($request instanceof Request && $response instanceof Response) {
		$response->send(200, $request->routeParams);
	} else {
		throw new ServerException('IoC failed to resolve.');
	}
});



$router->post('articles/:id', function($ioc) {
    $request = $ioc->get('request');
	$response = $ioc->get('response');
	if ($request instanceof Request && $response instanceof Response) {
		$response->send(200, $request->routeParams);
	} else {
		throw new ServerException('IoC failed to resolve.');
	}
});