Skip to content

Commit

Permalink
Añadido archivo cron.php para poder ejecutar el cron desde línea de c…
Browse files Browse the repository at this point in the history
…omandos.
  • Loading branch information
NeoRazorX committed Aug 4, 2022
1 parent 861f696 commit f861324
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
45 changes: 45 additions & 0 deletions cron.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
/**
* This file is part of FacturaScripts
* Copyright (C) 2017-2022 Carlos Garcia Gomez <carlos@facturascripts.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

use FacturaScripts\Core\Controller\Cron;
use FacturaScripts\Core\Session;
use FacturaScripts\Core\Setup;

if (php_sapi_name() !== "cli") {
die("Please use command line: php cron.php\n");
}

// checks the PHP version
if (version_compare(PHP_VERSION, '7.2') < 0) {
die('You need PHP 7.2 or later<br/>You have PHP ' . phpversion());
}

// set up the autoloader
require_once __DIR__ . '/vendor/autoload.php';

// change to the file folder, to prevent path problems
chdir(__DIR__);

// set up the config and session
Setup::load(__DIR__);
Session::init();

// run the cron controller
$cron = new Cron('');
$cron->run();
5 changes: 3 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,22 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

// checks the PHP version
use FacturaScripts\Core\Kernel;
use FacturaScripts\Core\Session;
use FacturaScripts\Core\Setup;

// checks the PHP version
if (version_compare(PHP_VERSION, '7.2') < 0) {
die('You need PHP 7.2 or later<br/>You have PHP ' . phpversion());
}

// set up the autoloader and config
// set up the autoloader
require_once __DIR__ . '/vendor/autoload.php';

// set up the error handler
register_shutdown_function('FacturaScripts\\Core\\Kernel::errorHandler');

// set up the config and session
Setup::load(__DIR__);
Session::init();

Expand Down

0 comments on commit f861324

Please sign in to comment.