-2

In my custom class.

<?php
  namespace CustomHelpers\API;

class api {

  public function __construct()
  {
  }

  public function api_login($data =[])
  {
     $respond = $this->api_function('admin_login', $data);
  }

  public function api_function($name, $request, $data = [])
  {
    $url = $name;
  }
}

File structure:

-app
--CustomHelpers
---API
----api.php

Composer.json

 "autoload": {
    "classmap": [
        "app/commands",
        "app/controllers",
        "app/models",
        "app/database/migrations",
        "app/database/seeds",
        "app/tests/TestCase.php"
    ],
    "psr-4": {
      "CustomHelpers\\": "app/CustomHelpers"
    }

},

Class 'CustomHelpers\API\App' not found

I've done what is in the manual but it the error is shown is weird because I don't have an APP inside my API folder. I use the command of composer dump-autoload Hope someone can help me.

Update

use CustomHelpers\API;

 public function login()
 {
   $new = new CustomHelpers\API\api();
   $session = $new->api_login(array('token'=>$token));
 }
aldrin27
  • 3,407
  • 3
  • 29
  • 43

1 Answers1

0

I managed it myself.

Class 'CustomHelpers\API\App' not found

This error up here is finds the class of App or the facade of App inside my customer helper class.

<?php
namespace CustomHelpers\API;
use Illuminate\Support\Facades\App; //I add this line and solve my problem

class api {

    public function __construct() {
    }

  public function api_login($data =[])
  {
    $respond = $this->api_function('admin_login', $data);
  }

  public function api_function($name, $request, $data = [])
  {
     $url = $name;
   }
}
aldrin27
  • 3,407
  • 3
  • 29
  • 43