Search code examples
phplaravelfpdf

FatalErrorException Class 'Codedge\Fpdf\FpdfServiceProvider' not found


The question is this, I have a development in Laravel 5.0 and developed a small module to create a pdf using the FPDF library, the issue is that my local server works correctly, but when I upload the files to my web server I throw the following error:

FatalErrorException in ProviderRepository.php line 150: Class 'Codedge\Fpdf\FpdfServiceProvider' not found

I did everything what the documentation indicates, nevertheless it still does not work correctly, I leave the code for its analysis

composer.json

{
  "name" : "laravel/laravel",
  "description" : "The Laravel Framework.",
  "keywords": ["framework", "laravel"],
  "license": "MIT",
  "type": "project",
  "require" : {
    "laravel/framework" : "5.0.*",
    "illuminate/html" : "~5.0",
    "yajra/laravel-datatables-oracle" : ">=v4.0.1",
    "doctrine/dbal": "~2.5",
    "laracasts/testdummy": "~2.0",
    "laracasts/flash": "~1.3",
    "barryvdh/laravel-debugbar": "~2.0",
    "khill/lavacharts": "3.0.x-dev",
    "conekta/conekta-php": "dev-master",
    "codedge/laravel-fpdf": "^1.2",
    "anouar/fpdf": "^2.0"
  },
  "require-dev" : {
    "phpunit/phpunit" : "~4.0",
    "phpspec/phpspec" : "~2.1",
    "laracasts/generators": "~1.0",
    "anouar/fpdf": "1.0.2"
  },
  "autoload": {
    "classmap": [
      "database"
    ],
    "psr-4": {
      "App\\": "app/"
    }
  },
  "autoload-dev": {
    "classmap": [
      "tests/TestCase.php"
    ]
  },
  "scripts": {
    "post-install-cmd": [
      "php artisan clear-compiled",
      "php artisan optimize"
    ],
    "post-update-cmd": [
      "php artisan clear-compiled",
      "php artisan optimize"
    ],
    "post-create-project-cmd": [
      "php -r \"copy('.env.example', '.env');\"",
      "php artisan key:generate"
    ]
  },
  "config": {
    "preferred-install": "dist"
  }
}

app.php

'providers' => [
        /*
         * Application Service Providers...
         */
        Codedge\Fpdf\FpdfServiceProvider::class,
    ],
'aliases' => [
        'Fpdf' => Codedge\Fpdf\Facades\Fpdf::class,
    ],

According to the documentation I did what this page told me

https://github.com/codedge/laravel-fpdf

In local it works without any problem, but online it sends the error that comments

Any help


Solution

  • Try to remove service provider and alias from config/app.php, then run:

    composer update
    php artisan vendor:publish --provider="Codedge\Fpdf\FpdfServiceProvider" --tag=config
    composer dump-autoload
    

    Then add service provider and alias back to config/app.php.