PHP Classes

File: src/JaxonServiceProvider.php

Recommend this page to a friend!
  Classes of Thierry Feuzeu   Jaxon for Laravel   src/JaxonServiceProvider.php   Download  
File: src/JaxonServiceProvider.php
Role: Class source
Content type: text/plain
Description: Class source
Class: Jaxon for Laravel
Laravel plugin to call PHP classes from with AJAX
Author: By
Last change: Changed route definition.
Apply fixes from StyleCI
Compatibility with the latest jaxon-core 3.0.x version.
Fixed the alias definition is service provider.
Allow integration with Jaxon DI.
Date: 3 years ago
Size: 1,092 bytes
 

Contents

Class file image Download
<?php

namespace Jaxon\Laravel;

use
Illuminate\Support\ServiceProvider;

class
JaxonServiceProvider extends ServiceProvider
{
   
/**
     * Bootstrap the application events.
     *
     * @return void
     */
   
public function boot()
    {
       
// Config source and destination files
       
$configSrcFile = __DIR__ . '/../config/config.php';
       
$configDstFile = config_path('jaxon.php');
       
// Publish assets and config
       
$this->publishes([
           
$configSrcFile => $configDstFile,
        ],
'config');
       
// Load package routes
       
if(!$this->app->routesAreCached())
        {
            require(
__DIR__ . '/../routes/web.php');
        }
    }

   
/**
     * Register the service provider.
     *
     * @return void
     */
   
public function register()
    {
       
// Register the Jaxon singleton
       
$this->app->singleton(Jaxon::class, function () {
           
$jaxon = new Jaxon();
           
$jaxon->setup();
            return
$jaxon;
        });
       
// Define the alias
       
$this->app->alias(Jaxon::class, 'jaxon');
    }
}