My question is simple and may be very basic. What is the best way to convert HTML pages to Laravel.?
In HTML pages the links are like <a href="about-us.html">
,
we have to convert it to <a href="{{ URL::asset('about-us.html')}}">
for Laravel.
Now i am manually editing entire HTML code to achieve it. Is there any short way to do it.?(i used replace all in CodeIgniter) Or What is the best way to avoid this overwork? Any other workflow between designer and programmer?
Note: Please comment here if you dont understand this question well. I will edit it.:)
Laravel provides various in built tags to handle HTML forms easily and securely. All the major elements of HTML are generated using Laravel. To support this, we need to add HTML package to Laravel using composer.
use Spatie\Browsershot\Browsershot; Here's the easiest way to create an image of a webpage: Browsershot::url('https://example.com')->save($pathToImage); By default the screenshot's type will be a png.
The web server will know that everything between <? php and ?> is php code and will execute it, the rest will be sent directly to the browser, because it is just static HTML. So, you can “convert” every html page to php just by renaming the file with . php extension.
The easiest way is,
Copy all HTML files, and paste them into the view folder.
Change all files extensions from .html to .blade.php (eg. about.html
to about.blade.php
).
Remove the '.html' from all anchors href, so <a href='about.html'>
will be <a href='about'>
. (Just replace .html with "" ).
Copy all other files/folders (js folder, CSS folder, image folder, etc) from the root folder to the public folder.
Create a route for your static pages. You can create a route for each page or you can create a single common route for all pages, like this.
Route::get('{page_name}', function($page_name)
{
//
return View::make('frontend/'.$page_name);
});
There is no way to do this without editing each and every page.
Laravel is based on Routing
. So you can't convert your link to,
<a href="{{ URL::asset('about-us.html')}}">
Note the about-us.html
. Instead of this you should do this,
First make a Route
in app/routes.php
Route::get('about', function()
{
return View::make('about');
});
Then save your about-us.html
file as about.blade.php
in app/views
.
And you can make the link like this,
{{ HTML::link('about', 'About Us') }}
For better html conversion, see the HTMLBuilder API
here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With