Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linux class not found #4

Closed
lokielse opened this issue Sep 7, 2013 · 13 comments
Closed

linux class not found #4

lokielse opened this issue Sep 7, 2013 · 13 comments
Assignees
Labels

Comments

@lokielse
Copy link

lokielse commented Sep 7, 2013

Class 'Liebig\Cron\models\Manager' not found

if (self::isDatabaseLogging()) {
// Get the time (in seconds) between this and the last run and save this to $timeBetween
$lastManager = \Liebig\Cron\models\Manager::orderBy('rundate', 'DESC')->take(1)->get();
if (!empty($lastManager[0])) {
$lastRun = new \DateTime($lastManager[0]->rundate);

@ghost ghost assigned liebig Sep 7, 2013
@liebig
Copy link
Owner

liebig commented Sep 7, 2013

I got a message at the Laravel forum that someone has this problem, too. Maybe this is a problem with linux only. I will install a local Debian on Monday and will try to fix this. Can you provide me a route definition snippet which you use and get this error?

@lokielse
Copy link
Author

lokielse commented Sep 7, 2013

1st=====================
config/app.php
alias
'Cron' => '\Liebig\Cron\Cron',

2nd==================
Route::get('cron/c56ac54aff5505bcb04259303bdf8d18',
function () {
Cron::setDatabaseLogging(true);
Cron::add('test_cron',
'* * * * * *',
function () {
ca_log('test cron', 'cron.test');
}
);
Cron::run();
return 'success';
}
);

@lokielse
Copy link
Author

lokielse commented Sep 7, 2013

.\vendor\liebig\cron\src\Liebig\Cron\Cron.php

namespace Liebig\Cron;
require_once DIR.'/models/manager.php'; //add this line and solve.

@liebig
Copy link
Owner

liebig commented Sep 7, 2013

Thank you very much for improving Cron. I will test your fix with Linux and Windows and will give you a feedback.

@liebig
Copy link
Owner

liebig commented Sep 9, 2013

I am sorry, but at my test environment it is working without your fix. I am running debian on virtual box with apache2. This is my Route file:

Route::get('cron/c56ac54aff5505bcb04259303bdf8d18', function () {
\Liebig\Cron\Cron::setDatabaseLogging(true);
\Liebig\Cron\Cron::setLogOnlyErrorJobsToDatabase(false);
\Liebig\Cron\Cron::add('test_cron', '* * * * * *', function () {
return 'test cron is running!';
});
return \Liebig\Cron\Cron::run();
});

And this works fine. I fixed the migration case sensitive bug, so please update to head and update your database. Did you use composer to install Cron?

@lokielse
Copy link
Author

lokielse commented Sep 9, 2013

The same code, it works on windows, but not work on debian.
There is no "models/manage" and "models/job" in generated classmap file which under vender/composer after i run "update" and "dump-autoload" on debian.
I don't know if it is problem between usage : 'Cron' => '\Liebig\Cron\Cron' ; Cron::xxx and \Liebig\Cron\Cron:xxx"
(when i use \Liebig\Cron\Cron::xxx will occur an errors, PHP 5.4.9)

@liebig
Copy link
Owner

liebig commented Sep 9, 2013

Strange issue! Okay, I will add two require_once commands to Cron. Can you please add this two lines and test Cron before I commit the change?

namespace Liebig\Cron;
require_once DIR . '/models/job.php';
require_once DIR . '/models/manager.php';

Thanks.

@lokielse
Copy link
Author

lokielse commented Sep 9, 2013

yes~ already.

liebig added a commit that referenced this issue Sep 9, 2013
…t via the composer autoloader - so we load them the old way

Issue #4 - Thanks to waisir for the great help
@liebig
Copy link
Owner

liebig commented Sep 9, 2013

Fixed - thanks again for the great help, waisir!

@liebig liebig closed this as completed Sep 9, 2013
@lucasmingarro
Copy link

Liebig I think that waisir has something wrong in his env/conf. I really don't know where but I'm using your package in OSX, Redhat and ubuntu an it works fine. How many coders report this issue?

@liebig
Copy link
Owner

liebig commented Sep 9, 2013

Thanks, lucasmingarro for your comment. At the moment we have two coders with this problem. I tested everything on Windows 7 and Debian 7.1.0 and it worked. But I can live with the fix because it doesen't mean much overhead. Only if the Cron class is loaded, the two model classes will be loaded, if they are not already. Only if you disable database logging in general, this two classes are not necessary but are loaded. To reach the best compatibility, I decided to commit this fix. I hope you can live with this, too ;)

@lucasmingarro
Copy link

hahahaha. I can live with my code so living with this hack will not be a problem :-)

@ryanwinchester
Copy link

I am having Class 'Liebig\Cron\Facades\Cron' not found in Ubuntu 13.04, Laravel 4.1, PHP 5.4.9

Fresh install of Laravel and fresh install of Cron, following the Install directions in Readme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants