InfyOm Labs

InfyOm Labs Blog

1 year ago in Troubleshooting

Fix datatables_css or datatables_js not found or failed to open stream

Recently, we introduced some breaking updates by which many developers are getting something from following errors:

  • datatables_css.stub failed to open stream
  • datatables_js.stub failed to open stream
  • View [datatables_css] not found
  • View [datatables_js] not found

Problem:

so, the purpose of this breaking update was, till now when we generate CRUD with datatables we were including datatable scripts into table.blade.php something like following:

{!! $dataTable->table(['width' => '100%']) !!}

@section('scripts')
    <link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.0.3/css/buttons.dataTables.min.css">
    <script src="https://cdn.datatables.net/buttons/1.0.3/js/dataTables.buttons.min.js"></script>
    <script src="vendor/datatables/buttons.server-side.js"></script>
    {!! $dataTable->scripts() !!}
@endsection

And the main css files for datatables were included into layout file layout/app.blade.php, also some js files were also included in the same folder. Like following,

<!-- Datatables -->
<script src="https://cdn.datatables.net/1.10.11/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.11/js/dataTables.bootstrap.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.2.1/js/dataTables.buttons.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.2.1/js/buttons.colVis.min.js"></script>

so the problem that we found was, when we want to update the datatables version, we have to go to each file and update them manually. Also there were some redundant JS and CSS files which were included into both table.blade.php & app.blade.php.

Solution:

As a solution, we decided to move this things to two partial files datatables_css.blade.php & datatables_js.blade.php. Which were published during publishing layout.

php artisan infyom.publish:layout

so if anyone is getting this error then, run composer update to update your code to latest commits and then try to run above command and publish these two files into your layouts folder. As an alternative, you can also create those files manually from the templates and can update your layout file accordingly.

If anyone is still facing issue after performing these steps, then please post your comments below.

···

Mitul Golakiya

CEO & Founder at InfyOm.com
comments powered by Disqus


© 2017 InfyOm Labs ยท Proudly powered by Canvas