Support the ongoing development of Laravel.io →
Configuration Architecture

I have a Laravel 5 application as the backend, serving AngularJS from a different directory (which is now assigned as the public path of Laravel) using this code on my

bootstrap/app.php

// set the public path to this directory
$app->bind('path.public', function() {
    return __DIR__.'/../../../client';
});

Then on routes.php

Route::get('{angular?}', [ 'uses' => 'HomeController@index' ])->where('angular', '.*');

Last the controller will just return the index.html file on the AngularJS directory

// HomeController@index
public function index()
{
    return \File::get(public_path().'/index.html');
}

The problem I'm having is that the scripts are not being loaded and when viewing it in chrome inspector looking at the resources, for example app.js all it contains is the entire index.html and because of this I'm getting the

Unexpected Token <

The reason I separated AngularJS directory and not serve it from app/public is that there other backend framework involved.

Last updated 2 years ago.
0

When you changed the location of the public directory, did you copy all the assets that were in laravel\public to the new directory?

0

@basementjack I'm trying to follow the example set here

  • Client Folder (Will be using index.html)
  • PHP (The Laravel public directory is pointed to the Client Folder)

So yes, I think I have moved most of the files. Not unless you mean I also need to move the .htaccess file?

0

Sign in to participate in this thread!

Eventy

Your banner here too?

lozadaOmr lozadaomr Joined 11 Mar 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.