Can not load css and js file slim 4, twig

I can not load css file and js file. I am editing a GitHub example. it is codecourse/slender 2.1.1". please anybody can help me.

Found a way in internet. It work for me. Below code for public folder index.php

if (PHP_SAPI == 'cli-server') {

    $_SERVER['SCRIPT_NAME'] = basename(__FILE__);

    // To help the built-in PHP dev server, check if the request was actually for

    // something which should probably be served as a static file

    $url  = parse_url($_SERVER['REQUEST_URI']);

    $file = __DIR__ . $url['path'];

    if (is_file($file)) {

        return false;



after can use

<link rel="stylesheet" type="text/css" href="{{ base_url }}assest/vendor/bootstrap/css/bootstrap.min.css">

don’t use {{ base_url() }} like this. It doesn’t work!

I use webpack to manage css/js files. Along with webpack, I use the Twig Webpack Extension. Once I have added this to my Twig config, it gives me access to webpack_entry_css and webpack_entry_js, which I can use directly in my twig files.

My webpack config can be found here.

1 Like