PHP code example of modulusphp / upstart

1. Go to this page and download the library: Download modulusphp/upstart library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

modulusphp / upstart example snippets




/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer has classes that we need to get our application running, all
| we need to do is just load it onto our script and we should be good to
| go!
|
*/

 Modulus\Upstart\Application::boot(realpath(__DIR__ . '/../'));

$app->make(new Modulus\Upstart\Boot\BugsnagHandler);

$app->make(new Modulus\Upstart\Boot\WhoopsHandler);

$app->make(new Modulus\Upstart\Boot\EloquentHandler);

$app->make(
  new Modulus\Upstart\Boot\ApplicationServices([
    'httpFoundation' => App\Http\HttpFoundation::class,
    'handler' => App\Exceptions\Handler::class,
    'routerResolver' => App\Resolvers\RouterResolver::class,
    'appServiceResolver' => App\Resolvers\AppServiceResolver::class
  ])
);

/*
|--------------------------------------------------------------------------
| Return The Application
|--------------------------------------------------------------------------
|
| Once the services have been loaded in the config, we will then return
| the instance of the application.
|
*/

return $app;



/**
 * Modulus - A cool API Framework for PHP
 *
 * @package Modulus
 * @author  Donald Pakkies <[email protected]>
 */

define('MODULUS_START', microtime(true));

/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| Before we can run the application, we will need to get it from the
| bootstrap, after getting it, we will be able to build a response and
| send it back to the browser.
|
*/

$app = 

#!/usr/bin/env php


/**
 * Modulus - A cool API Framework for PHP
 *
 * @package  Modulus
 * @author   Donald Pakkies <[email protected]>
 */

define('MODULUS_START', microtime(true));

/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| Before we can run the application, we will need to get it from the
| bootstrap, after getting it, we will be able to build a response and
| send it back to the browser.
|
*/

/** @var \Modulus\Upstart\Application $app */
$app = ------------------------------------------
|
| To get craftsman to run, we just need to pass it to the response make
| make method, "make" will return a response back to the terminal. So
| let's see if this works.
|
*/

return Modulus\Upstart\Response::make($app);



namespace App\Resolvers;

use Modulus\Upstart\Service;

class AppServiceResolver extends Service
{
  /**
   * Register application services
   *
   * @return void
   */
  protected function boot() : void
  {
    //
  }
}



namespace App\Resolvers;

use Modulus\Upstart\Resolvers\Router\Service;

class RouterResolver extends Service
{
  /**
   * Redirect route after authentication
   *
   * @var string
   */
  public const HOME = '/';

  /**
   * Register application routes
   *
   * @return void
   */
  protected function boot() : void
  {
    $this->apiRoutes();
    $this->webRoutes();
  }

  /**
   * Load api routes
   *
   * @param object $app
   * @return void
   */
  protected function apiRoutes() : void
  {
    $this->route->make(base_path('routes/api.php'))
        ->middleware('api')
        ->prefix('api')
        ->register();
  }

  /**
   * Load web routes
   *
   * @return void
   */
  protected function webRoutes() : void
  {
    $this->route->make(base_path('routes/web.php'))
        ->middleware('web')
        ->register();
  }
}