Using with Laravel

I have a Laravel project and wanna run EmberJS with it (without having separate servers). For this to work, I just pass the responsibility of web routing to EmberJS, but allow Laravel to do the API routing. However, for this to work, I will need the index.php and .htaccess files in the public/ directory in Laravel, but EmberJS should also keep its files there. So whenever I run ember-cli’s build , the build files should go to /public (which I’ve got working), but they must not override index.php and .htaccess, but overwrite any other file. Any way to achieve this?

Thanks!

I believe ember-cli has a --output-path=some-build-directory option, but that will delete some-build-directory before each build. I’m guessing that’s deleting your .htaccess and index.php files.

I think to solve this I would write a bash script that first runs ember build and then loops over all the build files and copies them into Laravel’s public directory. That way you get fresh Ember files on every build, but you won’t delete any existing files in public.

Yup, you’re right. Your solution is exactly what others suggested as well. However, to make getting the app up and running as easy as possible (the people that are going to be setting it up are computer noobs), I just decided to make the ember build files go to /public/app, and then in my backend Laravel routing, I just give the responsibility of routing to EmberJS by serving “/app/index.html”. It works like a charm :slight_smile:.

// Allow for the front-end framework to take control over all the other routing.
Route::get('{data?}', function() {
    // Serve the "index.html" file that controls the whole frontend.
    return View::file('app/index.html');
})->where('data', '.*');

https://www.npmjs.com/package/ember-cli-deploy-sftp deploy’s via sftp but does not remove files on the target.

An other way is to move the .htaccess and the index.php to the ember public folder if they almost never change.