Laravel 5 Hosting Asset Files - php

I have seen many questions here regarding Laravel 5 finding css and script assets. I have done what those answers suggest, mainly using a blade.php template and using either asset() or URL::asset, but sadly none of these work. I suspect something else is wrong here.
I am getting to my view directly, using http://[MyIP]/[ProjectName]/resources/views/[MyFile].blade.php in the address bar. My scripts and css are in the public folder, within directories javascript and css respectively.
When I load [MyFile].blade.php, which looks like so:
<title>My File</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<link rel="stylesheet" href="{{ URL::asset('css/font-awesome.min.css')}}">
<link rel="stylesheet" href="{{ URL::asset('css/animatemolly.css')}}">
<link rel="stylesheet" href="{{ asset('css/molly.css')}}">
<script src="{{ URL::asset('javascript/jquerymin.js')}}"></script>
It finds none of those. And in the served page, I get this error:
GET http://[MyIp]/[ProjectName]/resources/views/%7B%7B%20URL::asset('javascript/jquerymin.js')%7D%7D
It's like w/e Laravel service should be converting these into something useful isn't running at all? Do I need to install something further? I was under the impression that using it this way came with Laravel 5, according to this answer: Laravel stylesheets and javascript don't load for non-base routes... so I must be having some other problem, please advise.

You cannot go to your blade template directly, it must be rendered first by the templating engine. You usually do that in your controller.

Related

dompdf dont load bootstrap css with barryvdh/laravel-dompdf

i use barryvdh/laravel-dompdf in laravel 5.5 and bootstrap css (renamed to pdf.css with small adjustments) to generate a report in pdf
this is my header from the report view calling the css:
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link href="{{public_path('css/pdf.css') }}" rel="stylesheet" type="text/css" />
</head>
<body>
my controller:
public function infor(News $news)
{
...
PDF::setOptions(['dpi' => 150, 'defaultFont' => 'sans-serif']);
$pdf = PDF::loadView('admin.news_events.pdf');
return $pdf->stream('pdfview.pdf');
}
Expected view (html5):
view generated in pdf :,(
How could I solve this?
You have to put all css file in style tag to launch your code
barryvdh/laravel-dompdf does not support boostrap yet.
Quoting the author:
I highly doubt that DomPDF can handle Bootstrap correctly.
If you need better pdf, try: https://github.com/barryvdh/laravel-snappy
That used Webkit to render pdf.
See more about the issue here
I had the same issue, all I did was create another blade file, copied bootstrap.css contents into it (between style tags) , then included it (the file with the css) in the file I wanted to print
Change your file path to this, if CSS and images are not inside the public directory.
<img src="{{ base_path().'/location/to/image/image.png' }}" />
<link rel="stylesheet" type="text/css" href="{{ base_path().'/location/css/bootstrap.min.css' }}">
You should use another version of bootstrap. because i tested it with bootstrap 3 and it's not working but it works with version 4 of the framework.

CSS file isn't properly linked when I change the .html file to a .php

This problem is exclusive to the index.html file, and as I said before, the CSS that works when it's an html, stops working when the extension is changed. I inspected the ref link on both instances and when it's a php, the CSS files end up being the php file itself. I'm assuming that it maybe can't access the css for some weird reason? I'm not sure how that translates to only when it's a php. I've done the same procedure to other pages, and it works fine.
If it means anything, part of what stops working is the Foundation I'm using.
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Foundation</title>
<link rel="stylesheet" href="stylesheets/app.css" />
<link rel="stylesheet" href="stylesheets/main.css" />
<script src="bower_components/modernizr/modernizr.js"></script>
<script src="js/foundation/foundation.js"></script>
<script src="js/foundation/foundation.clearing.js"></script>
</head>
I also found that any href links stop working as well.
I guess it is delivered using a wrong MIME type. Try forcing CSS MIME type by setting the headers like below:
header("Content-type: text/css");
Moreover, make sure that, using PHP, you should execute using a server. i.e., the following URL is right:
http://domain/path/to/index.php
http://localhost/project/index.php
And not:
file:///c:/wamp/www/project/index.php
file:///c:/myproject/index.php
file:///c:/xampp/htdocs/index.php

Issue linking CSS to backend Zend Framework 1

I am working on a Zend Framework 1 application. It is successfully installed on my localhost and is working without any problems. However I've noticed that the css for the back end of the application is not working.
When I view the page source I can see the stylesheet has been loaded and can click on the link to it to view in the browser.
However the style is not applied to any of the elements on the screen and I do not understand why.
This is the layout file for the page: (adminstyle.css is not loading...)
<link href="/css/adminstyle.css" media="all" rel="stylesheet" type="text/css" title="default" />
<link rel="stylesheet" href="/css/smoothness/jquery-ui-1.10.2.custom.min.css">
<link rel="shortcut icon" href="images/favicon_2.ico" />
</head>
does anyone know what might be causing this issue? Apologies for the question if it seems stupid but I'm not really experienced with this sort of thing and I am trying to get to the bottom of it. Any help is much appreciated.
I can provide more details if required, I just do not want to post lots of unescessary snippets of code up.
Here is the right way to write links in zend framework cause with your way it will work just for the index/index , for other view you won't get the style css applied :
<link rel='stylesheet' type='text/css' href="<?php echo $this->baseUrl()."/css/style.css"; ?>" >
the same for your js files
hope it helps.

Changing header for PHP website

I am trying to make a website in PHP (I don't really have any experience in this). What I did was use an existing website that somebody created for me and just went about changing things in the .php files.
I had this in header.php:
<base href="http://old-domain.com/"; />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<link rel="stylesheet" type="text/css" href="css/default.css?v=4" />
<link rel="shortcut icon" href="favicon.ico" />
I just changed the 'old-domain' to 'new-domain'.
Now, my homepage of the 'new-domain' looks fine. But all other pages, like new-domain.com/help or new-domain.com/about give me a 404.
On the other hand, when I change the 'new-domain' back to 'old-domain', it displays my old website properly, so I guess this means that the code is alright.
What am I doing wrong? Do I need to set up new-domain.com/help, etc somewhere else?
Thank you.
Just check whether any other file contains the link www.old-domain.com and change it to www.new-domain.com.
I assume the project structure is the same.
because there is no seperate php file for those pages create seperate file for each like help.php and about.php and then include those in header

Using LESS css in Codeigniter

Is there a way to implement a LESS stylesheet in a codeigniter project without having to rely on sparks and Carabiner?
In the of my view in CI, I place the link to the LESS file, and the LESS.js file directly underneath, however when I view the site, CI doesn't recognize the .LESS file. I've tried using relative paths as well as hardcoding the the file directories directly, however nothing changes. Is there something I should try adding to my config file to load the LESS files properly?
My file structure for the CI project is as follows
application
controllers
views
system
js
less-1.2.2.min.js
plugins.js
css
style.css
style.less
As for my header, its based off of the html5 boilerplate, to save space I'll only include the relevant info.
application -> views -> layout.php
<meta name="viewport" content="width=device-width">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<link rel="stylesheet/less" type="text/css" media="screen" href="css/style.less">
<script src="js/less-1.2.2.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" media="screen" href="css/style.css">
<!-- end CSS-->
Are you using mod_rewrite in httpd.conf? If so, you need to make sure that .less files are exempted.
RewriteCond %{REQUEST_URI} !(^alocalfarmCI/index\.php|\.png$|\.gif$|\.less$|\.js$|\.css$|/robots
One way to easily tell if this is your problem, type in a non-existent url within your site that ends in .less. If you see CI's error page, that means /index.php/ was inserted in the url.
If you're running with client-side (javascript) LESS, Codeigniter won't be involved in how LESS operates. Be sure that you've set the rel attribute appropriately when you're linking your LESS file in your views and that the less.js file is being loaded correctly.
<link rel="stylesheet/less" type="text/css" href="styles.less">
<script src="less.js" type="text/javascript"></script>

Categories