Laravel URL::asset for 404's view - laravel

I'm embellishing Laravel's 404 page (ressources/views/erros/404.blade.php). But, I can't load my CSS and JS files, which are, in my public folder.
Actually, Laravel is returning me localhost/css/bootstrap.css when it should return me localhost/myproject/public/css/bootstrap.css with {{ URL::asset('css/bootstrap.css') }}. While it's returning me localhost/myproject/public/css/bootstrap.css when I'm on another view (with the same code: {{ URL::asset('css/bootstrap.css') }}) on my home page wich is perfectly working.
By the way, I'm using Laravel 5.3.
Thanks in advance <3

Configure your webserver so the root of domain (localhost) points to public/ -folder.
Vagrant-solution like Homestead would probably make setting up the development-environment easier for you.

Related

Handle content which contains laravel blade code in vuejs

#Asking
Help me for my problem,
I have blog content and it has syntax examples like {{ $title }} because my content describes laravel blade.
Problem
When I render my blog content on Vuejs everything goes wrong because there is a sytax blade {{ $title }}
Any solution to this problem?
please use below code
{{ $title }} - use for laravel blade
{{{$title}}} - use for Vue js in laravel blade page
if you want to bind both please try with below code
In script tag
var title = '{{$title}}';
In Vue js CLI
data:return{ title:'{{$title}}' }
If you still getting a problem, then please brief all about your problem with the code I will resolve it.
I try to parse README.md file from hexters/rolevel and I render the README.md content with vuejs, and my apps error and Blank

Can't get Laravel-Filemanager to work in subfolder on remote server

In my Laravel 5.7 site I use Ckeditor together with Laravel-Filemanager. After following all the installation instructions I got it to work fine locally. No problems att all. But I cannot get it to work in my remote web server.
On the remote server I have placed the Laravel app in a subfolder 2 levels down from the webroot.
In my blade template I have this (I have tried using both asset and url helpers in the option urls and both of them works locally):
<script src="{{ asset('vendor/unisharp/laravel-ckeditor/ckeditor.js') }}"></script>
<script>
var options = {
filebrowserImageBrowseUrl: "{{ url('/laravel-filemanager?type=Images') }}",
filebrowserImageUploadUrl: "{{ url('/laravel-filemanager/upload?type=Images&_token=') }}"
};
</script>
<script>
CKEDITOR.replace('editor1', options);
</script>
When I want to upload an image in my CKeditor by clicking the Browse server button in my local environment it works as it should and the URL looks like this in Laravel File Manager ('laravel/' being the webroot):
http://laravel/laravel-filemanager?type=Images&CKEditor=editor1&CKEditorFuncNum=0&langCode=sv
When I do the same thing in my remote server the URL looks like this:
http://www.myremoteserver.com/subfolder1/subfolder2/public/laravel-filemanager?type=Images&CKEditor=editor1&CKEditorFuncNum=0&langCode=sv
... and all I get is a 404.
I have tried to clear route, config and site caches. I have also tried to copy the URL above in the remote environment and pasting it a new window without the /public/ part.
Is there anyone out there that can guess what is going on? All help would be greatly appreciated.
please share with me how got the ckeditor to upload files when you click send to server because i have being searching for it for about 2 days now yet no solution.
iam using laravel 5.7
and unisharp laravel-filemanager but no solution was found.
I only saw to add config.filebrowserUploadMethod = 'form';
in the ckeditor congi.js but even after adding that i still didn't get any solution.
every other things seems to be working fine.
please i will be glad to receive your assistance
I finally got it to work. I wiped the web server folder clean and uploaded all files again from the beginning manually instead of doing it by cloning the GIT repo. And then it worked. So I actually am not sure what was wrong.
Anyhow I added this snippet below where I wanted the CKeditor in my blade template:
<textarea id="editor1" name="story" class="form-control">{{ $story }}</textarea>
And this near the bottom of the blade template, just before #endsection.
<script src="{{ asset('vendor/unisharp/laravel-ckeditor/ckeditor.js') }}"></script>
<script>
var options = {
filebrowserImageBrowseUrl: "{{ url('/laravel-filemanager?type=Images') }}",
filebrowserImageUploadUrl: "{{ url('/laravel-filemanager/upload?type=Images&_token=') }}"
};
</script>
<script>
CKEDITOR.replace('editor1', options);
</script>
Be sure to publish as per the filemanager instructions:
php artisan vendor:publish --tag=lfm_config
php artisan vendor:publish --tag=lfm_public
And clear caches:
php artisan route:clear
php artisan config:clear
Also check that the vendor folder exists in your public directory with CKeditor and Laravel filemanager folders inside it, otherwise the asset and url helpers will not work. Also check in the dev window (F12 in browser) what your current path is to ckeditor.js.

Laravel mix hot reload and domain name

I use Laravel Homestead for my development environment, so my website is accessible on http://test.app
Now I tried to configure laravel mix to use it with VUEJS. For this, I include a JS file in one of my templates:
<script src="{{ url(mix('js/main.js'))}}"></script>
The result of this is
<script src="//localhost:8080/js/main.js"></script>
It seems so, that the localhost:8080 is hardcoded in vendor/laravel/framework/src/Illuminate/Foundation/helper.php (see https://github.com/laravel/framework/blob/e35a60f7f3ef1d75754522771f13762b3058f1b0/src/Illuminate/Foundation/helpers.php#L560)
How to fix this or how I done something wrong?
the source you quote will only be executed in watch mode.
In this case, Laravel mix host a server on 8080 port for all your static files (css, js) so you can get the hot-reload feature, while the php files still running on your Homestead Niginx, and I don't see anything wrong with it.
it will compile to your APP_URL in production mode and if 8080 is somehow conflicting with your other service you can modify config file of Laravel Mix.
try setting APP_URL in your .env config file
APP_URL = http://test.app
i hope it helps.

Including CSS in Laravel 5 or 4.3

TL;DR: What is the correct way to link to a stylesheet in Laravel 5?
Background:
I'm using the dev version of Laravel 4.3 (5) because I want to use Socialite, and it makes sense to develop with that from the start. I am having a problem getting templates transferred from 4.2
I've moved my blade layout files to the new directory structure (resources/templates) and placed my CSS in the public/css/ folder.
When I load my route /test/ all I get is "Whoops, looks like something went wrong."
For testing purposes I've removed all blade layout syntax from my layouts - the raw HTML works, but there is no styling (as there is no linked stylesheet). That tells me the routes, views and controllers work.
The problem:
In my layouts, if I remove the following, the layouts work:
{{ HTML::style('css/bootstrap.min.css') }}
{{ HTML::style('css/style.css') }}
Question:
What is the correct location and syntax for Blade Stylesheet inclusion in Laravel 5 and what I should be using instead?
The HtmlBuilder has been removed from Laravel's core, so HTML::style() is no longer available.
If you want to use it in laravel 5, add the following to your composer.json file, under the require key:
"laravelcollective/html": "~5.0"
Also note, since HTML::style() returns HTML code, you don't want it escaped. Use the raw brackets:
{!! HTML::style('css/style.css') !!}
Adding to #joseph's answer, for the users preferring not to switch to the new syntax, you can use
Blade::setRawTags('{{', '}}');
and continue with the old syntax . this can be set almost anywhere, but a better choice would be a service provider, say legacy service provide for l4 . you can find further discussion on this at laracasts, where you can find taylor otwells thoughts on this .
If you want to use plain HTML then use like this-
<link rel="stylesheet" href="/css/folder/style.css">

Codeigniter: Routes only visible when entering /index segments

I'm working on my first project with codeigniter 2.0 and have a bit of a problem.
On my localhost (a MAMP installation) everything works fine with the routes. Only when i add a copy on my domain, change the base url and other necessary settings like my database settings it works fine for like 99%. I can't access my other controllers directly without adding the /index route. For example when i want to visit the http://my_domain.com/work it'll open the 404 error page but when i enter ttp://my_domain.com/work/index it works fine. Does someone know a setting i have to change for the online version? The Htaccess files are identical.
CHeers in advance.
I found my solution. I just checked the routes.php file in my config where i added a route for every controller. I just removed these and only my default_controller route is left. Now it works fine. Just a codeigniter newbie issue.
Thanks anyways for the help #Hibiscus and #BigFatBaby
I sorted my problem by setting the following line as my .htaccess file.
RewriteEngine On
RewriteRule ^.*$ index.php [NC,L]
It'll rewrite anything after the /index.php/blaha to /blaha.

Resources