How to run php artisan cache:clear? Class Not Found

Website URL

[
(https://skd21.infinityfreeapp.com/)

Error Message

Class “Yajra\DataTables\DataTablesServiceProvider” not found

Other Information

Hello i just adding new vendor in my web , its Yajra Datatables. im already copying all my files but its keep error DataTablesServiceProvider not found. i need to run php artisan cache:clear or composer dump-autoload.
How to do that in infinity hosting?

You can run the commands on your local computer, then upload the resulting files over FTP.

Free hosting does not provide command line access.

10 Likes

I don’t know that much about the topic - so I’m sorry for any mistake here - but I searched and it looks that you’re trying to use a CLI, that is not supported on InfinityFree free hosting.

1 Like

i already upload all files 2 times . but its still class not found.

is there any way to fix class not found? already add in my config/app.php in providers and service. im done with vendor publish and add the datatables.php in config folder too.

Did you do this?

Would it be possible to share this configuration, ommiting any sensitive details (eg. passwords)?

What version of Yajra’s Laravel DataTables are you trying to use?

5 Likes

Hi john_statham,

This hosting does not offer CLI access meaning you cannot run commands on the server, you need to run it on your local computer using a command line tool.

The commands php artisan cache:clear and composer dump-autoload can be manually performed on the server after running on your local computer.

php artisan cache:clear
Simply means deleting all files under your-app-root/storage/framework/cache.

composer dump-autoload
Changes the vendor/autoload.php file and the composer directory right next to this file that contains all class names and path information, usually this file looks something like:
image
Replace vendor/autoload.php and all files with your local copy for files under vendor/composer.

After this check your library specifically to see if you have all of it’s updated files uploaded to the server. The class name Yajra\DataTables\DataTablesServiceProvider suggested the namespace for it being Yajra\DataTables meaning it’s not part of your code, it’s a library. You need to check for a folder likely named vendor/yajra or anything that suggests DataTables to see if the files are all there.

Once that’s done, it should work, or share with us your latest error message and we’ll help.

Cheers!

7 Likes
'providers' => [

        /*
         * Laravel Framework Service Providers...
         */
        Illuminate\Auth\AuthServiceProvider::class,
        Illuminate\Broadcasting\BroadcastServiceProvider::class,
        Illuminate\Bus\BusServiceProvider::class,
        Illuminate\Cache\CacheServiceProvider::class,
        Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
        Illuminate\Cookie\CookieServiceProvider::class,
        Illuminate\Database\DatabaseServiceProvider::class,
        Illuminate\Encryption\EncryptionServiceProvider::class,
        Illuminate\Filesystem\FilesystemServiceProvider::class,
        Illuminate\Foundation\Providers\FoundationServiceProvider::class,
        Illuminate\Hashing\HashServiceProvider::class,
        Illuminate\Mail\MailServiceProvider::class,
        Illuminate\Notifications\NotificationServiceProvider::class,
        Illuminate\Pagination\PaginationServiceProvider::class,
        Illuminate\Pipeline\PipelineServiceProvider::class,
        Illuminate\Queue\QueueServiceProvider::class,
        Illuminate\Redis\RedisServiceProvider::class,
        Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
        Illuminate\Session\SessionServiceProvider::class,
        Illuminate\Translation\TranslationServiceProvider::class,
        Illuminate\Validation\ValidationServiceProvider::class,
        Illuminate\View\ViewServiceProvider::class,
        Spatie\Permission\PermissionServiceProvider::class,
        Intervention\Image\ImageServiceProvider::class,
        Yajra\DataTables\DataTablesServiceProvider::class,
        /*
         * Package Service Providers...
         */

        /*
         * Application Service Providers...
         */
        App\Providers\AppServiceProvider::class,
        App\Providers\AuthServiceProvider::class,
        // App\Providers\BroadcastServiceProvider::class,
        App\Providers\EventServiceProvider::class,
        App\Providers\RouteServiceProvider::class,

    ],
'aliases' => [

        'App' => Illuminate\Support\Facades\App::class,
        'Arr' => Illuminate\Support\Arr::class,
        'Artisan' => Illuminate\Support\Facades\Artisan::class,
        'Auth' => Illuminate\Support\Facades\Auth::class,
        'Blade' => Illuminate\Support\Facades\Blade::class,
        'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
        'Bus' => Illuminate\Support\Facades\Bus::class,
        'Cache' => Illuminate\Support\Facades\Cache::class,
        'Config' => Illuminate\Support\Facades\Config::class,
        'Cookie' => Illuminate\Support\Facades\Cookie::class,
        'Crypt' => Illuminate\Support\Facades\Crypt::class,
        'DataTables' => Yajra\DataTables\Facades\DataTables::class,
]

this is yajra composer.json :

{
  "name": "yajra/laravel-datatables-oracle",
  "description": "jQuery DataTables API for Laravel 5|6|7|8|9",
  "keywords": [
    "laravel",
    "dataTables",
    "jquery"
  ],
  "license": "MIT",
  "authors": [
    {
      "name": "Arjay Angeles",
      "email": "[email protected]"
    }
  ],
  "require": {
    "php": "^7.1.3|^8",
    "illuminate/database": "5.8.*|^6|^7|^8|^9",
    "illuminate/filesystem": "5.8.*|^6|^7|^8|^9",
    "illuminate/http": "5.8.*|^6|^7|^8|^9",
    "illuminate/support": "5.8.*|^6|^7|^8|^9",
    "illuminate/view": "5.8.*|^6|^7|^8|^9"
  },
  "require-dev": {
    "orchestra/testbench": "^3.8|^4.0|^5.0|^6.0|^7.0"
  },
  "suggest": {
    "yajra/laravel-datatables-buttons": "Plugin for server-side exporting of dataTables.",
    "yajra/laravel-datatables-html": "Plugin for server-side HTML builder of dataTables.",
    "yajra/laravel-datatables-fractal": "Plugin for server-side response using Fractal.",
    "yajra/laravel-datatables-editor": "Plugin to use DataTables Editor (requires a license)."
  },
  "autoload": {
    "psr-4": {
      "Yajra\\DataTables\\": "src/"
    },
    "files": [
      "src/helper.php"
    ]
  },
  "autoload-dev": {
    "psr-4": {
      "Yajra\\DataTables\\Tests\\": "tests/"
    }
  },
  "extra": {
    "branch-alias": {
      "dev-master": "9.0-dev"
    },
    "laravel": {
      "providers": [
        "Yajra\\DataTables\\DataTablesServiceProvider"
      ],
      "aliases": {
        "DataTables": "Yajra\\DataTables\\Facades\\DataTables"
      }
    }
  },
  "config": {
    "sort-packages": true
  },
  "scripts": {
    "test": "vendor/bin/phpunit"
  },
  "minimum-stability": "dev",
  "prefer-stable": true
}

Hi john_statham,

From your code, I can see you have declaired that class in your providers and has it also defined as an alias, but this code does not reflect or tell me the fact whether the file exists.

You need to check carefully if the file is indeed explorable by composer’s autoloader by following the steps in the above reply, especially the part that regarding the vendor/composer directory, simply declaring the library in the composer.json is not enough.

Cheers!

6 Likes

ok its work right now. im optimized:clear on my locals and upload all file again

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.