Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Nadeem2020's avatar

flag-icon-css package installation and use in laravel

Hi all, I have installed a package what contains flag-icons. That is the github source: https://github.com/lipis/flag-icon-css

The installation guide is easy. But I am not able to use it in my laravel project. What I am doing wrong?

I used the following css/html code:

<span class="flag-icon flag-icon-gr"></span>

The package is available in my node_modules directory. I think that package is installed but my project is not referencing to it as I am doing it for php-packages via function asset('vendor...').

0 likes
8 replies
wingly's avatar

Did you try npm install && npm run dev

Nadeem2020's avatar

Yes, I did that couple of times. That the message:

Asset     Size   Chunks             Chunk Names
/css/app.css  0 bytes  /js/app  [emitted]  /js/app
  /js/app.js  592 KiB  /js/app  [emitted]  /js/app

My app.css is just empty, is that normal?

wingly's avatar
wingly
Best Answer
Level 29

@nadeem2020 probably you installed it but you don't import it. Never used the package but try adding import 'flag-icon-css/css/flag-icon.css' in your app.js and then recompile your assets

Nadeem2020's avatar

Hi, I have imported it into the resources/js/app.js file, after that I processed again npm install & npm run dev. On the first look it seems that it worked, but then I am getting that error message:

Warning: require_once(C:\xampp\htdocs\dzematApp/public/index.php): failed to open stream: No such file or directory in C:\xampp\htdocs\dzematApp\server.php on line 21

Fatal error: require_once(): Failed opening required 'C:\xampp\htdocs\dzematApp/public/index.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\dzematApp\server.php on line 21

Line 21 in server.php is: require_once DIR.'/public/index.php'; I realized that my index.php is just gone because of the compilation... I don't know how to get it back...

Nadeem2020's avatar

I am using all the time laravel mix. The documentation is not really helpful for beginners. The methods are explained but not where and when to use it.

Nadeem2020's avatar

Got it, I copied it from an older project. But thank you :)

my resources/js/app.js looks like that now:

require('./bootstrap');
import 'flag-icon-css/css/flag-icon.css';

Processed again npm install & npm rund dev.

/css/app.css     0 bytes  /js/app  [emitted]  /js/app
/js/app.js     902 KiB  /js/app  [emitted]  /js/app

My app.js becomes bigger. What is a good sign.

After inserting the app.js in bottom of the body area

    <script src="{{ asset('js/app.js') }}"></script>

It works for me now.

Thank you all for your help :)

Please or to participate in this conversation.