Code Monkey home page Code Monkey logo

Comments (5)

liebig avatar liebig commented on July 16, 2024

Can you print the whole error message please?

from cron.

ngyikp avatar ngyikp commented on July 16, 2024

Preparation:

$ composer create-project --prefer-dist laravel/laravel blog
$ cd blog
$ echo '' > routes/api.php
$ php artisan make:controller HomeController -r
$ echo '<?php Route::get("welcome", "HomeController@index");' > routes/web.php
$ composer require liebig/cron

Then add Liebig\Cron\Laravel5ServiceProvider to config/app.php

$ php artisan route:cache -v
Route cache cleared!


   LogicException  : Unable to prepare route [cron.php] for serialization. Uses Closure.

  at /tmp/blog/vendor/laravel/framework/src/Illuminate/Routing/Route.php:880
    876|      */
    877|     public function prepareForSerialization()
    878|     {
    879|         if ($this->action['uses'] instanceof Closure) {
  > 880|             throw new LogicException("Unable to prepare route [{$this->uri}] for serialization. Uses Closure.");
    881|         }
    882| 
    883|         $this->compileRoute();
    884| 

  Exception trace:

  1   Illuminate\Routing\Route::prepareForSerialization()
      /tmp/blog/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteCacheCommand.php:62

  2   Illuminate\Foundation\Console\RouteCacheCommand::handle()
      /tmp/blog/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29

  3   call_user_func_array([])
      /tmp/blog/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29

  4   Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
      /tmp/blog/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:87

  5   Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Object(Closure))
      /tmp/blog/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:31

  6   Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), [])
      /tmp/blog/vendor/laravel/framework/src/Illuminate/Container/Container.php:564

  7   Illuminate\Container\Container::call()
      /tmp/blog/vendor/laravel/framework/src/Illuminate/Console/Command.php:183

  8   Illuminate\Console\Command::execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
      /tmp/blog/vendor/symfony/console/Command/Command.php:252

  9   Symfony\Component\Console\Command\Command::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
      /tmp/blog/vendor/laravel/framework/src/Illuminate/Console/Command.php:170

  10  Illuminate\Console\Command::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      /tmp/blog/vendor/symfony/console/Application.php:865

  11  Symfony\Component\Console\Application::doRunCommand(Object(Illuminate\Foundation\Console\RouteCacheCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      /tmp/blog/vendor/symfony/console/Application.php:241

  12  Symfony\Component\Console\Application::doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      /tmp/blog/vendor/symfony/console/Application.php:143

  13  Symfony\Component\Console\Application::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      /tmp/blog/vendor/laravel/framework/src/Illuminate/Console/Application.php:88

  14  Illuminate\Console\Application::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      /tmp/blog/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:122

  15  Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      /tmp/blog/artisan:37

Laravel's documentation does mention this limitation:

Closure based routes cannot be cached. To use route caching, you must convert any Closure routes to controller classes.

from cron.

liebig avatar liebig commented on July 16, 2024

Thank you. Please update to head and test.

from cron.

ngyikp avatar ngyikp commented on July 16, 2024

Yup, it works. Feel free to close when the new version is released 👍

from cron.

liebig avatar liebig commented on July 16, 2024

Version 1.3 has been released.

from cron.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.