• Stars
    star
    2,338
  • Rank 19,675 (Top 0.4 %)
  • Language
    PHP
  • License
    MIT License
  • Created over 5 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Laravel UI utilities and presets.

Laravel UI

Total Downloads Latest Stable Version License

Introduction

While Laravel does not dictate which JavaScript or CSS pre-processors you use, it does provide a basic starting point using Bootstrap, React, and / or Vue that will be helpful for many applications. By default, Laravel uses NPM to install both of these frontend packages.

This legacy package is a very simple authentication scaffolding built on the Bootstrap CSS framework. While it continues to work with the latest version of Laravel, you should consider using Laravel Breeze for new projects. Or, for something more robust, consider Laravel Jetstream.

Official Documentation

Supported Versions

Only the latest major version of Laravel UI receives bug fixes. The table below lists compatible Laravel versions:

Version Laravel Version
1.x 5.8, 6.x
2.x 7.x
3.x 8.x
4.x 9.x, 10.x

Installation

The Bootstrap and Vue scaffolding provided by Laravel is located in the laravel/ui Composer package, which may be installed using Composer:

composer require laravel/ui

Once the laravel/ui package has been installed, you may install the frontend scaffolding using the ui Artisan command:

// Generate basic scaffolding...
php artisan ui bootstrap
php artisan ui vue
php artisan ui react

// Generate login / registration scaffolding...
php artisan ui bootstrap --auth
php artisan ui vue --auth
php artisan ui react --auth

CSS

Laravel officially supports Vite, a modern frontend build tool that provides an extremely fast development environment and bundles your code for production. Vite supports a variety of CSS preprocessor languages, including SASS and Less, which are extensions of plain CSS that add variables, mixins, and other powerful features that make working with CSS much more enjoyable. In this document, we will briefly discuss CSS compilation in general; however, you should consult the full Vite documentation for more information on compiling SASS or Less.

JavaScript

Laravel does not require you to use a specific JavaScript framework or library to build your applications. In fact, you don't have to use JavaScript at all. However, Laravel does include some basic scaffolding to make it easier to get started writing modern JavaScript using the Vue library. Vue provides an expressive API for building robust JavaScript applications using components. As with CSS, we may use Vite to easily compile JavaScript components into a single, browser-ready JavaScript file.

Writing CSS

After installing the laravel/ui Composer package and generating the frontend scaffolding, Laravel's package.json file will include the bootstrap package to help you get started prototyping your application's frontend using Bootstrap. However, feel free to add or remove packages from the package.json file as needed for your own application. You are not required to use the Bootstrap framework to build your Laravel application - it is provided as a good starting point for those who choose to use it.

Before compiling your CSS, install your project's frontend dependencies using the Node package manager (NPM):

npm install

Once the dependencies have been installed using npm install, you can compile your SASS files to plain CSS using Vite. The npm run dev command will process the instructions in your vite.config.js file. Typically, your compiled CSS will be placed in the public/build/assets directory:

npm run dev

The vite.config.js file included with Laravel's frontend scaffolding will compile the resources/sass/app.scss SASS file. This app.scss file imports a file of SASS variables and loads Bootstrap, which provides a good starting point for most applications. Feel free to customize the app.scss file however you wish or even use an entirely different pre-processor by configuring Vite.

Writing JavaScript

All of the JavaScript dependencies required by your application can be found in the package.json file in the project's root directory. This file is similar to a composer.json file except it specifies JavaScript dependencies instead of PHP dependencies. You can install these dependencies using the Node package manager (NPM):

npm install

By default, the Laravel package.json file includes a few packages such as lodash and axios to help you get started building your JavaScript application. Feel free to add or remove from the package.json file as needed for your own application.

Once the packages are installed, you can use the npm run dev command to compile your assets. Vite is a module bundler for modern JavaScript applications. When you run the npm run dev command, Vite will execute the instructions in your vite.config.js file:

npm run dev

By default, the Laravel vite.config.js file compiles your SASS and the resources/js/app.js file. Within the app.js file you may register your Vue components or, if you prefer a different framework, configure your own JavaScript application. Your compiled JavaScript will typically be placed in the public/build/assets directory.

The app.js file will load the resources/js/bootstrap.js file which bootstraps and configures Vue, Axios, jQuery, and all other JavaScript dependencies. If you have additional JavaScript dependencies to configure, you may do so in this file.

Writing Vue Components

When using the laravel/ui package to scaffold your frontend, an ExampleComponent.vue Vue component will be placed in the resources/js/components directory. The ExampleComponent.vue file is an example of a single file Vue component which defines its JavaScript and HTML template in the same file. Single file components provide a very convenient approach to building JavaScript driven applications. The example component is registered in your app.js file:

import ExampleComponent from './components/ExampleComponent.vue';
Vue.component('example-component', ExampleComponent);

To use the component in your application, you may drop it into one of your HTML templates. For example, after running the php artisan ui vue --auth Artisan command to scaffold your application's authentication and registration screens, you could drop the component into the home.blade.php Blade template:

@extends('layouts.app')

@section('content')
    <example-component></example-component>
@endsection

Remember, you should run the npm run dev command each time you change a Vue component. Or, you may run the npm run watch command to monitor and automatically recompile your components each time they are modified.

If you are interested in learning more about writing Vue components, you should read the Vue documentation, which provides a thorough, easy-to-read overview of the entire Vue framework.

Using React

If you prefer to use React to build your JavaScript application, Laravel makes it a cinch to swap the Vue scaffolding with React scaffolding:

composer require laravel/ui

// Generate basic scaffolding...
php artisan ui react

// Generate login / registration scaffolding...
php artisan ui react --auth

Adding Presets

Presets are "macroable", which allows you to add additional methods to the UiCommand class at runtime. For example, the following code adds a nextjs method to the UiCommand class. Typically, you should declare preset macros in a service provider:

use Laravel\Ui\UiCommand;

UiCommand::macro('nextjs', function (UiCommand $command) {
    // Scaffold your frontend...
});

Then, you may call the new preset via the ui command:

php artisan ui nextjs

Contributing

Thank you for considering contributing to UI! The contribution guide can be found in the Laravel documentation.

Code of Conduct

In order to ensure that the Laravel community is welcoming to all, please review and abide by the Code of Conduct.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

License

Laravel UI is open-sourced software licensed under the MIT license.

More Repositories

1

laravel

Laravel is a web application framework with expressive, elegant syntax. We’ve already laid the foundation for your next big idea — freeing you to create without sweating the small things.
PHP
75,490
star
2

framework

The Laravel Framework.
PHP
30,766
star
3

lumen

The Laravel Lumen Framework.
PHP
7,644
star
4

tinker

Powerful REPL for the Laravel framework.
PHP
7,241
star
5

socialite

Laravel wrapper around OAuth 1 & OAuth 2 libraries.
PHP
5,407
star
6

telescope

An elegant debug assistant for the Laravel framework.
PHP
4,631
star
7

homestead

Shell
3,850
star
8

jetstream

Tailwind scaffolding for the Laravel framework.
PHP
3,804
star
9

horizon

Dashboard and code-driven configuration for Laravel queues.
PHP
3,719
star
10

octane

Supercharge your Laravel application's performance.
PHP
3,533
star
11

passport

Laravel Passport provides OAuth2 server support to Laravel.
PHP
3,184
star
12

docs

The Laravel documentation.
2,816
star
13

sanctum

Laravel Sanctum provides a featherweight authentication system for SPAs and simple APIs.
PHP
2,623
star
14

pint

Laravel Pint is an opinionated PHP code style fixer for minimalists.
PHP
2,580
star
15

valet

A more enjoyable local development experience for Mac.
PHP
2,498
star
16

breeze

Minimal Laravel authentication scaffolding with Blade, Vue, or React + Tailwind.
PHP
2,469
star
17

cashier-stripe

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.
PHP
2,291
star
18

dusk

Laravel Dusk provides simple end-to-end testing and browser automation.
PHP
1,788
star
19

envoy

Elegant SSH tasks for PHP.
PHP
1,545
star
20

fortify

Backend controllers and scaffolding for Laravel authentication.
PHP
1,500
star
21

sail

Docker files for running a basic Laravel application.
Shell
1,468
star
22

lumen-framework

The Laravel Lumen Framework.
PHP
1,455
star
23

scout

Laravel Scout provides a driver based solution to searching your Eloquent models.
PHP
1,455
star
24

pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.
PHP
1,443
star
25

breeze-next

An application / authentication starter kit frontend in Next.js for Laravel Breeze.
JavaScript
1,116
star
26

reverb

Laravel Reverb provides a real-time WebSocket communication backend for Laravel applications.
PHP
1,095
star
27

echo

Laravel Echo library for beautiful Pusher and Ably integration.
TypeScript
1,085
star
28

elixir

Fluent API for Gulp.
JavaScript
1,080
star
29

settler

Shell
1,013
star
30

ideas

Issues board used for Laravel internals discussions.
943
star
31

slack-notification-channel

Slack Notification Channel for laravel.
PHP
829
star
32

vite-plugin

Laravel plugin for Vite.
TypeScript
783
star
33

helpers

Provides backwards compatibility for helpers in the latest Laravel release.
PHP
735
star
34

vonage-notification-channel

Vonage Notification Channel for Laravel.
PHP
709
star
35

pail

Dive into your Laravel application's log files directly from the console. 🪣
PHP
564
star
36

folio

Page based routing for Laravel.
PHP
561
star
37

nova-issues

554
star
38

laravel.com

The source code of the official Laravel website.
Blade
531
star
39

installer

The Laravel application installer.
PHP
527
star
40

browser-kit-testing

Provides backwards compatibility for BrowserKit testing in the latest Laravel release.
PHP
497
star
41

forge-sdk

The official Laravel Forge PHP SDK.
PHP
491
star
42

serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closures in PHP.
PHP
434
star
43

spark-legacy

PHP
428
star
44

pennant

A simple, lightweight library for managing feature flags.
PHP
408
star
45

vapor-core

The core service providers and runtime client for Laravel Vapor.
PHP
399
star
46

quickstart-basic

A sample task list application.
PHP
391
star
47

cashier-mollie

PHP
376
star
48

prompts

Beautiful and user-friendly forms for your command-line PHP applications.
PHP
357
star
49

spark-installer

PHP
314
star
50

nova-docs

The Laravel Nova documentation.
TypeScript
310
star
51

vapor-cli

The CLI client for interacting with Laravel Vapor.
PHP
303
star
52

vapor-ui

The Laravel Vapor UI.
Vue
265
star
53

quickstart-intermediate

A sample task list application with authentication.
PHP
262
star
54

blog-contest-may-mayhem

244
star
55

cashier-paddle

Cashier Paddle provides an expressive, fluent interface to Paddle's subscription billing services.
PHP
239
star
56

forge-cli

The Laravel Forge CLI.
PHP
219
star
57

spark-aurelius

PHP
202
star
58

art

Laravel logo and other artwork.
190
star
59

spark-tests

174
star
60

cashier-braintree

PHP
164
star
61

vapor-php-build

Dockerfile
132
star
62

nova-log-viewer

A Laravel Nova tool for viewing your application logs
PHP
118
star
63

legacy-factories

PHP
118
star
64

precognition

Anticipate the outcome of a future HTTP request.
TypeScript
115
star
65

nova-js

JavaScript
113
star
66

jetstream-js

JavaScript
107
star
67

forge-monitor

PHP
105
star
68

forge-database-backups

Shell
104
star
69

bootcamp.laravel.com

Laravel Bootcamp
PHP
98
star
70

nova-dusk-suite

PHP
93
star
71

vapor-laravel-template

PHP
86
star
72

lumen-docs

The Lumen documentation.
84
star
73

lumen-installer

PHP
76
star
74

jetstream-docs

The Jetstream documentation.
TypeScript
69
star
75

legacy-encrypter

PHP
60
star
76

.github

Source code of the default community health files for the Laravel organization.
52
star
77

vapor-dockerfiles

Dockerfile
49
star
78

vapor-docs

The Vapor documentation.
TypeScript
49
star
79

discord-bot

TypeScript
39
star
80

vapor-js

JavaScript
36
star
81

spark-aurelius-mollie

Laravel Spark, Mollie edition
PHP
28
star
82

spark-docs

The Spark Classic documentation.
27
star
83

nova-mix

JavaScript
26
star
84

envoyer-docs

The Envoyer documentation.
TypeScript
23
star
85

sail-server

The build website for new Laravel Sail apps.
PHP
19
star
86

facade-documenter

Laravel's Facade docblock generator.
PHP
15
star
87

spark-next-docs

The Spark documentation.
TypeScript
9
star