Laravel Horizon is a powerful dashboard and management tool for Laravel queues. It provides real-time monitoring, configuration options, and insights into your application's queued jobs. If you want to integrate Laravel Horizon with Vue.js for a more dynamic and interactive experience, you can follow these steps:
Install Laravel Horizon:
bashcomposer require laravel/horizon php artisan horizon:install
Configure Horizon:
Update your config/horizon.php
file with the necessary configurations.
Run Horizon: Start the Horizon dashboard using the following command:
bashphp artisan horizon
Access the Horizon dashboard at http://your-app.com/horizon
.
Integrate Vue.js: Horizon's default UI is built using Vue.js, but if you want to create a custom Vue.js application, you can do so by including Vue.js in your project. Make sure you have Vue.js installed via npm or include it from a CDN.
Create a Vue Component: Create a Vue component that will interact with Horizon API endpoints. You can use Laravel Mix to compile your Vue components.
javascript// resources/js/components/HorizonMonitor.vue
<template>
<div>
<!-- Your Vue component HTML structure -->
</div>
</template>
<script>
export default {
data() {
return {
// Your component data
};
},
mounted() {
// Fetch data from Horizon API endpoints
this.fetchHorizonData();
},
methods: {
fetchHorizonData() {
// Use Axios or any other HTTP library to fetch data from Horizon API
},
},
};
</script>
<style scoped>
/* Your component styles */
</style>
Make API Requests:
Inside the fetchHorizonData
method, make API requests to Horizon's endpoints to retrieve the necessary data for your Vue component. You can use Laravel's Horizon API endpoints to get information about jobs, workers, metrics, etc.
Display Data: Update your component to display the fetched data in an interactive way. You can use charts, tables, or any other visualization library to represent the queue metrics.
Include Component in Blade View: Include your Vue component in a Blade view where you want to display the Horizon monitoring.
html<!-- resources/views/horizon.blade.php -->
@extends('layouts.app')
@section('content')
<horizon-monitor></horizon-monitor>
@endsection
Compile Vue Components: If you are using Laravel Mix, make sure to run the following command to compile your Vue components:
bashnpm run dev
Visit the Page: Visit the page where you included your Vue component, and you should see your custom Vue.js Horizon monitoring dashboard.
Remember to customize the Vue component according to your application's needs and use appropriate styling and visualization libraries for a better user experience.