# Can not load css and js file slim 4, twig

**URL:** <https://discourse.slimframework.com/t/can-not-load-css-and-js-file-slim-4-twig/3974>\
**Category:** Questions\
**Created:** [March 29, 2020, 5:03pm UTC](https://discourse.slimframework.com/t/can-not-load-css-and-js-file-slim-4-twig/3974 "2020-03-29T17:03:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![madushancs](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/madushancs/32/1100_2.png) [@madushancs](https://discourse.slimframework.com/u/madushancs)\
**Post date:** [March 29, 2020, 5:03pm UTC](https://discourse.slimframework.com/t/can-not-load-css-and-js-file-slim-4-twig/3974/1 "2020-03-29T17:03:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![madushancs](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/madushancs/32/1100_2.png) [@madushancs](https://discourse.slimframework.com/u/madushancs)\
**Post date:** [March 29, 2020, 5:26pm UTC](https://discourse.slimframework.com/t/can-not-load-css-and-js-file-slim-4-twig/3974/2 "2020-03-29T17:26:16Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![darkalchemy](https://avatars.discourse-cdn.com/v4/letter/d/ad7895/32.png) [@darkalchemy](https://discourse.slimframework.com/u/darkalchemy)\
**Post date:** [March 31, 2020, 3:26pm UTC](https://discourse.slimframework.com/t/can-not-load-css-and-js-file-slim-4-twig/3974/3 "2020-03-31T15:26:16Z")

</div>

I use webpack to manage css/js files. Along with webpack, I use the [Twig Webpack Extension](https://github.com/fullpipe/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](https://github.com/darkalchemy/Slim-Auth/tree/master/webpack).
