Search code examples
phplaravelroutesrequire-once

laravel access native php script


I'm trying to run a native php script using laravel routes.php , view, controller. but no chance.

for example if i have a test.php inside views path and require it in a view blade:

 <?php
    require_once 'test.php';
 ?>

then build a route to that view and point to it:

 FatalErrorException in b012cb264e405ddcdbcd54b1275905692fac6df9.php line 26:
 main(): Failed opening required 'test.php' (include_path='.;E:\xampp\php\PEAR')

Solution

  • Try something like

    require_once base_path('resources/views').'/test.php';
    

    Or This is in your config/view.php

    require_once Config::get('view.paths').'/test.php';
    

    Laravel 5+ (Global config)

    require_once config('view.paths').'/test.php';