Migrating from 4.1 to 5

Migrating from 4.1 to version 5 might include an awful lot of work. Version 4.1 will be supported for the foreseeable future but will only contain patch fixes.

Update the app.php aliases

First, you'll need to update your app.php. Remove all Bootstrapper aliases and replace them with the following:

'Accordion' => 'Bootstrapper\Facades\Accordion',
'Alert' => 'Bootstrapper\Facades\Alert',
'Badge' => 'Bootstrapper\Facades\Badge',
'Breadcrumb' => 'Bootstrapper\Facades\Breadcrumb',
'Button' => 'Bootstrapper\Facades\Button',
'ButtonGroup' => 'Bootstrapper\Facades\ButtonGroup',
'Carousel' => 'Bootstrapper\Facades\Carousel',
'ControlGroup' => 'Bootstrapper\Facades\ControlGroup',
'DropdownButton' => 'Bootstrapper\Facades\DropdownButton',
'Form' => 'Bootstrapper\Facades\Form',
'Helpers' => 'Bootstrapper\Facades\Helpers',
'Icon' => 'Bootstrapper\Facades\Icon',
'InputGroup' => 'Bootstrapper\Facades\InputGroup',
'Image' => 'Bootstrapper\Facades\Image',
'Label' => 'Bootstrapper\Facades\Label',
'MediaObject' => 'Bootstrapper\Facades\MediaObject',
'Modal' => 'Bootstrapper\Facades\Modal',
'Navbar' => 'Bootstrapper\Facades\Navbar',
'Navigation' => 'Bootstrapper\Facades\Navigation',
'Panel' => 'Bootstrapper\Facades\Panel',
'ProgressBar' => 'Bootstrapper\Facades\ProgressBar',
'Tabbable' => 'Bootstrapper\Facades\Tabbable',
'Table' => 'Bootstrapper\Facades\Table',
'Thumbnail' => 'Bootstrapper\Facades\Thumbnail',

Secondly, attributes are now passed in using the withAttributes() chained method.

Finally, all objects that need to be turned into a string will now fail gracefully if an exception is thrown during render. This will print out the following string

An exception of type $class was thrown with the message: $message

If you wish to override this behaviour, call the render() method on the object explicitly.

Individual Component Changes

Please see the components below for the full changelist. If something is not covered, please open an issue!

Accordion

  • The create() method has now been removed in favour of the more descriptive named() method.
  • The Accordion will throw an AccordionException if the accordion is not named using the named() method.
  • withContents() now expects you to be explicit with your array keys. Instead of using withContents([['First', 'Content'], ['Second', 'Content']]), use withContents([['title' => 'First', 'contents' => 'Content']])
  • withContents() no longer accepts a second parameter to default open the accordion. This should be done with the open()
  • Indexing for the open method now begins at 0, instead of 1.

Alert

  • Alerts now default to the old open() method - that is, that if you want the closing × to be generated for you, you now must use the chainable close() method.
  • The block() method has now been removed (since .alert-block was removed in Bootstrap 3).

Badges

  • The normal() method has been renamed to withContents()

Breadcrumbs

  • The create() method has been removed and renamed withLinks()

Buttons

  • There are no longer any magic method calls. Calls such as lg_primary('content') should now be primary('content')->large().
  • The lg(), sm() and xs() functions have been extended to their full names (large(), small(), extraSmall() respectively).
  • The link() function now creates a button with class .btn-link. To create an <a> tag, use the asLinkTo() function.

Button Groups

  • create() has been renamed withContents().
  • withContents() no longer expects an array of arrays, instead expecting an array of string-like objects (usually a Button object).

Button Toolbars

  • This class has now been removed. When grouping Button Groups, wrap them with:
    <div class="btn-toolbar" role="toolbar">
    
    ...
    </div>

Carousels

  • The create() method has been renamed withContents()
  • Carousels should be named using the named() method. Failure to do so will throw a Bootstrapper\Exceptions\CarouselException.
  • The inner arrays for withContents() should use the keys image, caption and alt.

Dropdown Buttons

  • There are no longer any magic method calls. Calls such as lg_primary() should now be primary()->large().
  • The lg(), sm() and xs() functions have been extended to their full names (large(), small(), extraSmall() respectively).
  • primary(), danger(), warning(), success(), info() and normal() no longer accept 3 arguments. Use withContents() and withAttributes().

Form

  • *_open() methods have been removed.
  • *_open_for_files(), *_open_secure(), *_open_secure_for_files() have been removed. Use the standard Laravel methods for secure or file forms.
  • horizontal_model() etc have been renamed horizontalModel.
  • *_append_with_button etc have been removed. Use the InputGroup class instead.

Helpers

  • Bootstrapper\Helpers::get_CSS() should be replaced with Helpers::css().
  • Bootstrapper\Helpers::get_JS() should be replaced with Helpers::js().

Icons

  • Icons work exactly the same as before. Woo!

Images

  • Images work exactly the same as before. Woo!

Label

  • Labels work the same as before. Woo!

Media Objects

  • create() has been renamed withContents() and expects an array of arrays.
  • All old chained methods have now been removed. Use the inner arrays in withContents() instead.
  • open_list() and close_list() have been removed. Use the asList() chained method instead.

Modals

  • create() has been removed.

Navbars

  • The Navbar::create() call now takes parameters in the opposite order (giving Navbar::create($position, $attributes = []). Previous calls such as Navbar::create(['role' => 'navigation'], Navbar::FIX_TOP) should now be Navbar::create(Navbar::FIX_TOP, ['role' => 'navigation'])
  • Similarly, Navbar::inverse() now has the signature Navbar::inverse($position, $attributes)
  • with_brand() has been renamed withBrand().
  • with_menus() has been renamed withContent().
  • withContent() now expects either a Navigation object or a string. It can survive being given any other object, as long as it has a __toString() implementation.

Navigation

  • Navigation::links() has been removed. Use pills() or tabs()
  • pills() and tabs() now only expect an array argument, instead of the return value of Navigation::links.
  • There is no longer a boolean flag in pills() or tabs() method signatures to make the result stacked. Instead, use the chained method stacked().
  • The array arguments for pills() or tabs() must be explicit. Instead of using ['Home', url('home')], you must use ['title' => 'Home', 'link' => url('home'). Support for the older shorthand method may return, depending on requests. If you feel it important, please open an issue.

Pagination

This class has now been removed. Use the standard Laravel paginator instead.

Panels

  • header(), body(), footer() have been renamed withHeader() etc

Progress Bars

This class has now been renamed to ProgressBar from Progress.

  • Magic methods have been removed. Calls such as Progress::normal_striped(20) should now be ProgressBar::normal(20)->striped()

Tables

  • open() and close() have been removed.
  • Table types are now added to the table object itself, instead of appended to the open() method.
  • headers() has been removed.
  • body() has been renamed withContents().
  • always_ignore() has been removed.
  • Dynamic methods have now been removed. Instead, use the callback() function.

Typography

This class has now been removed. Use the standard Bootstrap classes for the relevant tags.

Migrating to 4.1 of Bootstrapper

Sizing calls

You used to be able to size your input fields by making your standard call with span*_ in front of the function name. Bootstrap 3 now requires field sizing to be done by wrapping them inside a .col-xs-* instead.

Old Way which doesn't work

Form::span1_text('t_span1', 'span1')
Form::span2_text('t_span2', 'span2')
Form::span3_text('t_span3', 'span3')

Form::span1_select('s_span1', array('1', '2', '3', '4', '5'))
Form::span2_select('s_span2', array('1', '2', '3', '4', '5'))
Form::span3_select('s_span3', array('1', '2', '3', '4', '5'))

New Way

<div class='col-xs-1'>
  Form::text('t_span1', 'span1')
</div>
<div class='col-xs-2'>
  Form::text('t_span2', 'span2')
</div>
<div class='col-xs-3'>
  Form::text('t_span3', 'span3')
</div>

<div class='col-xs-1'>
  Form::select('s_span1', array('1', '2', '3', '4', '5'))
</div>
<div class='col-xs-2'>
  Form::select('s_span2', array('1', '2', '3', '4', '5'))
</div>
<div class='col-xs-3'>
  Form::select('s_span3', array('1', '2', '3', '4', '5'))
</div>

Button Groups

Button Groups have now changed completely from before - instead of calling ButtonGroup::open(ButtonGroup::TOGGLE_CHECKBOX), Button::primary('foo') and ButtonGroup::close(), now you call ButtonGroup::checkbox(array(array(ButtonGroup::PRIMARY, 'foo')))

Old Way doesn't work

//Checkbox  
ButtonGroup::open(ButtonGroup::TOGGLE_CHECKBOX)
Button::danger_normal('Left')
Button::danger_normal('Middle')
Button::danger_normal('Right')
ButtonGroup::close()

//Radio  
ButtonGroup::open(ButtonGroup::TOGGLE_RADIO)
Button::primary_normal('Left')
Button::primary_normal('Middle')
Button::primary_normal('Right')
ButtonGroup::close()

New Way

//Checkbox  
ButtonGroup::checkbox(array(
	array(ButtonGroup::DANGER, 'Left'),
	array(ButtonGroup::DANGER, 'Middle'),
	array(ButtonGroup::DANGER, 'Right')
	))

//Radio  
ButtonGroup::radio(array(
	array(ButtonGroup::PRIMARY, 'Left'),
	array(ButtonGroup::PRIMARY, 'Middle'),
	array(ButtonGroup::PRIMARY, 'Right')
	))