PHP code example of dansol / webpack-encore-view-helper

1. Go to this page and download the library: Download dansol/webpack-encore-view-helper 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/ */

    

dansol / webpack-encore-view-helper example snippets



return [
	...
    'webpack_encore_view_helper_config'=>[
		/* webpack encore entry points */
        'entrypoints_map' => json_decode(file_get_contents(__DIR__ . '/../../public/build/entrypoints.json'),true),
		/* map view to entrypoint ( array can be empty if templates name match entrypoint name when using auto* parameters */
        'template_entrypoint_map'=>[
			
			'layout::default'=>'app',
        ]
    ]
];


$aggregator = new ConfigAggregator([
	// ... other stuff 
    \WebpackEncoreViewHelper\ConfigProvider::class,
    // Default App module config
      new PhpFileProvider(realpath(__DIR__) . '/autoload/{{,*.}global,{,*.}local}.php'),
    // Load development config if it exists
    new PhpFileProvider(realpath(__DIR__) . '/development.config.php'),
], $cacheConfig['config_cache_path']);

...
// load asset ( in layout template)
$this->webpack_encore_assets('common entrypointname'); // if used a common entry

// load asset ( in template that consume an entrypoint)
$this->webpack_encore_assets('common entrypointname'); // if used a common entry

// in layout template
// render link tags
echo $this->webpack_encore_assets()->render('css');
...
// render script tags
echo $this->webpack_encore_assets()->render('js');

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    <link rel="shortcut icon" href="https://getlaminas.org/images/favicon/favicon.ico" />
    <?=$this->headTitle('mezzio')->setSeparator(' - ')->setAutoEscape(false)