0

How to configure url or base url in Laravel4.2 for secures protocol https without set manual in html builder.

{{ HTML::style('front_assets/plugins/bootstrap/css/bootstrap.min.css') }}
        {{ HTML::style('front_assets/css/style.css')}}
        <!-- CSS Implementing Plugins -->

        {{ HTML::style('front_assets/plugins/font-awesome/css/font-awesome.min.css') }}
        {{ HTML::style('front_assets/plugins/sky-forms/version-2.0.1/css/custom-sky-forms.css') }}

        {{ HTML::style('front_assets/plugins/scrollbar/src/perfect-scrollbar.css') }}
        {{ HTML::style('front_assets/plugins/fullcalendar/fullcalendar.css') }}
        {{ HTML::style('front_assets/plugins/fullcalendar/fullcalendar.print.css',array('media' => 'print')) }}
DMS-KH
  • 2,669
  • 8
  • 43
  • 73

1 Answers1

0

It's not clear what you need. If you page URL is in https scheme, every asset URL on that page will be generated in https automatically, but if you need only certain types of assets to be linked by https on page requested by http, you have to implement your own custom HtmlBuilder that overrides helper methods you need to be forced to generate https URLs

<?php namespace MyApp\Html;

use Illuminate\Html\HtmlBuilder;

class MyAppHtmlBuilder extends HtmlBuilder {

    public function style($url, $attributes = array(), $secure = true)
    {                                                            ^^^^
        return parent::style($url, $attributes, $secure)
    }
}

Then in app.php config you should replace default HtmlServiceProvider with your custom MyAppHtmlServiceProvider.

<?php namespace MyApp\Html;

use Illuminate\Html\HtmlServiceProvider;
use MyApp\Html\MyAppHtmlBuilder;

class MyAppHtmlServiceProvider extends HtmlServiceProvider {

    protected function registerHtmlBuilder()
    {
        $this->app->bindShared('html', function($app)
        {
             return new MyAppHtmlBuilder($app['url']);
        });
    }
}
HongKilDong
  • 1,276
  • 3
  • 16
  • 23