Home > Article > PHP Framework > Laravel development: How to use Laravel Nova and AdminBro to generate a backend management interface?
Laravel is a popular PHP web application framework with rich features and tools to help developers build web applications faster and easier. Laravel Nova and AdminBro are two open source frameworks that can help us quickly generate beautiful backend management interfaces. This article will introduce how to use them to achieve rapid development and get your application online quickly.
1. Understanding Laravel Nova and AdminBro
Laravel Nova is a beautiful and easy-to-use backend management panel developed by Taylor Otwell and his team. It provides some powerful features, such as : Resource management, filtering and sorting, custom dashboards, etc. Additionally, using multiple components, you can easily customize Nova's style and appearance.
AdminBro is an extensible backend admin panel for Node.js and Typescript. It uses React as the user interface library, with responsive design and ease of use. Developers can use AdminBro to develop their own admin The panel, meanwhile, can have its appearance and behavior customized as desired.
2. Install and configure Laravel Nova
Before you begin, you need to make sure you have the latest version of Laravel installed in your project. In your project, use composer to update and install the latest version of Laravel Nova.
composer require laravel/nova
The installation process may take a while, and you need to log in to Laravel Nova's official website to register your Nova application and register for authorization.
Once completed, you need to add Nova to your routing file. This can be achieved using the following statement:
Route::get('/nova', function () { return redirect('/nova/login');});
You can also add this statement to your routing file so that the admin panel will only be available to authorized users.
Route::middleware(['auth'])->group(function () { Route::get('/nova', function () { return redirect('/nova/ login'); }); Nova::routes();});
Here, you can use the Nova::routes() method to specify which routes will be used by nova. After the setup is complete, you can now access your newly added /Admin route and successfully log in to the Nova control panel.
3. Install and configure AdminBro
Compared with Laravel Nova, AdminBro can run in the Node.js environment. It is a plug-in architecture that supports various extensions, such as strongly typed input of various input values, customized preview, filtering, sorting and other functions.
Installing AdminBro is very easy. First you need to install two necessary dependencies.
npm install admin-bro
npm install @admin-bro/express
Next, you need to install Set up AdminBro on the application and then enable AdminBro on the router where you can set routing paths and handlers.
const AdminBro = require('admin-bro') const AdminBroExpress = require('@admin-bro/express') const express = require('express') const adminBro = new AdminBro() const router = AdminBroExpress.buildRouter(adminBro) const app = express() app.use(adminBro.options.rootPath, router) app.listen(8080, () => { console.log('Server running')})
After enabling AdminBro in your Express application, you need to create an AdminBro configuration object that contains all entities.
const Cars = require('./entities/cars') const Users = require('./entities/users') const adminBroOptions = { resources: [{ resource: Cars, options: { properties: { name: { isTitle: true }, gearbox: { components: { list: AdminBro.bundle('./path/to/custom/components/list') } }, }, }, }, Users] } const adminBro = new AdminBro(adminBroOptions)
Here we create a code that has our entity attached to it. You can use the program as a template to add custom entities, properties, and components.
4. Use Laravel Nova and AdminBro to manage your data
Now that we have installed Laravel Nova and AdminBro in our application and configured them, we can use them to create a custom admin panel. While these frameworks are very similar in some ways, they are slightly different in others.
1. Resource management: Laravel Nova provides a simple but powerful resource manager that allows you to easily and simply manage resources, such as articles, authors, comments, orders, using Laravel's convenient ORM ( object relational mapping). AdminBro can also perform similar operations, but it requires the use of new entity classes and data sources from its own, which may take more time.
2. Fields and Properties: Laravel Nova and AdminBro's admin panel allows you to easily add input, display, and format fields by installing plugins or custom components. Both frameworks support creating fields, but Nova has more field components. In contrast, AdminBro's custom components allow you to manage certain components more directly, such as selectors and radio buttons.
3. View customization: Laravel Nova uses Blade as the default template engine. So you can use the core templating system in Laravel to define views. At the same time, Nova can also use Vue to develop custom components. Since AdminBro uses React as its default user interface library, you need to use React to develop your custom views.
Conclusion
Laravel Nova and AdminBro are both great frameworks that can help developers create beautiful and easy-to-use admin panels in web applications faster. They work slightly differently, but you can decide which framework to use based on your needs. Now, you only need to follow the above steps to configure and use these two frameworks in your application, ensuring maximum efficiency improvement in your learning and development and getting your application online faster.
The above is the detailed content of Laravel development: How to use Laravel Nova and AdminBro to generate a backend management interface?. For more information, please follow other related articles on the PHP Chinese website!