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

jim1506's avatar

Call a PHP page (not blade) from a controller

I have been battling Datatables with 5.4 without any success and have decided that I will have to walk another route as I cannot give it more time.

I have therefore a page in the public area in a subdirectory called ajax, datatables_users.php.

This page generates a datatable using server side processing fine (which I could never get to work in 5.4) so I just want to call it from a controller.

I have tried

return view("asset('ajax\datatables_user.php')") ;

but I am getting a

Class Barstone\Http\Controllers\../ajax/datatables_user.php does not exist

How can a call a "raw" php page from a controller?

Thanks

0 likes
2 replies
SaeedPrez's avatar

Move the file to your resources/views folder and you call it exactly like you call a blade template.

// This will return either of these
//    resources/views/test.blade.php 
//    resources/views/test.php
return view('test');

Edit:

If you really want to keep the views in your public folder, add the path to your config/view.php file..

    'paths' => [
        realpath(base_path('resources/views')),
        // add it here
    ],

Please or to participate in this conversation.