3

I'm new on Laravel and need some help. Actually I use 5.3 Laravel version. I need to use, in Laravel, external company framework (call it F for simplicity). This framework is some like process manager. Actually, for integrate it with laravel I put it in laravel/public folder, this way I can use laravel and F's pages in same domain. In laravel I need to access to some F functionality which is all collect in class FFramework\Facade\FInterface; Then I want to access to this class from laravel controller FController. But when I run code I get Class Not Found Exception.

This is folder structure:

  • laravel
    • app
      • http
        • controllers
          • FController.php
  • public
    • css
    • js
    • index.php
      • fframework
        • facade
          • FInterface.php
        • index.php

This is code example:

FController.php

<?php
  namespace App\Http\Controllers;

  use FFramework\facade\FInterface;

  class FController extends Controller {

      public function getSimpleDAta() {
          $f = new FInterface();
          return $f->getSimpleData();
    }
  }

FInterface.php

<?php
  namespace FFramework\facade;

  use some\internal\function;
  
  class FInterface {

      public function getSimpleDAta() {
          $simpleData = ...omg so much computation :) ...
          return $simpleData;
    }
  }
  

Exception that I get:

Class 'FFramework\facade\FInterface' not found

Additional Information

I use standard LAMP configuration PHP version is last 5.6 stable version

Question

How can I use FInterface from Laravel controller leaving FFramework in public folder?

1
  • Laravel uses composer's autoloader, add the namespace and path to the autoload section in composer.json. Commented Dec 23, 2016 at 15:25

1 Answer 1

1

You need to update the autoload section of your composer.json file to tell your project where to look for files in the FFramework namespace.

"autoload": {
    "classmap": [
        "database"
    ],
    "psr-4": {
        "App\\": "app/"
        "FFramework\\": "public/fframework"
    }
},
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.