<commit_before><?php

/*
 * This file is part of the Pho package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Pho\Cli;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Output\OutputInterface;

use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;

class ServeCommand extends Command
{

    protected $server, $kernel, $founder;

    protected function configure()
    {
        $this
            ->setName('serve')
            ->setDescription('Run server based on pho Graph ')
            ->addOption('kernel', 'k',  InputOption::VALUE_OPTIONAL, 'Kernel path');

    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $kernel_path = $input->getOption('kernel');

        if (empty($kernel_path) || !file_exists($kernel_path))  {
            var_dump($kernel_path);
            throw new \InvalidArgumentException('Kernel path not exists;');
            return;
        }

        include_once(rtrim($kernel_path, DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php');
        if ( ! class_exists('\\Pho\\Kernel\\Kernel')) {
            throw new \InvalidArgumentException('Kernel class not founded in current path:' . $kernel_path);
            return;
        }

        $dotenv = new Dotenv\Dotenv($kernel_path);
        $dotenv->load();
        $configs = array(
          "services"=>array(
                "database" => getenv('DATABASE_URI'),
                "storage" => getenv("STORAGE_URI"),
          ),
          "default_objects" => array(
                "graph" => class_exists(\PhoNetworksAutogenerated\Twitter::class) ? \PhoNetworksAutogenerated\Twitter::class : ( class_exists(\PhoNetworksAutogenerated\Facebook::class) ? \PhoNetworksAutogenerated\Facebook::class : \PhoNetworksAutogenerated\Graph::class ),
                "founder" => User::class,
          )
        );

        $this->kernel = new \Pho\Kernel\Kernel($this->config);
        $this->founder = new \PhoNetworksAutogenerated\User($this->kernel, $this->kernel->space(), $input->getOption('password'));
        $this->kernel->boot($this->founder);


        $this->server = new \Pho\Server\Rest\Daemon($this->kernel);
        $this->server->setPort(1337);
        //eval(\Psy\sh());
        $this->server->serve($input->getOption('port'), $input->getOption('host'));
    }
}<commit_msg>Small env changes to the serve command<commit_after><?php

/*
 * This file is part of the Pho package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Pho\Cli;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Output\OutputInterface;

use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;

class ServeCommand extends Command
{

    protected $server, $kernel, $founder;

    protected function configure()
    {
        $this
            ->setName('serve')
            ->setDescription('Run server based on pho Graph ')
            ->addOption('kernel', 'k',  InputOption::VALUE_OPTIONAL, 'Kernel path');

    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $kernel_path = $input->getOption('kernel');

        if (empty($kernel_path) || !file_exists($kernel_path))  {
            var_dump($kernel_path);
            throw new \InvalidArgumentException('Kernel path not exists;');
            return;
        }

        include_once(rtrim($kernel_path, DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php');


        $dotenv = new Dotenv\Dotenv($kernel_path);
        $dotenv->load();
        
        if ( ! class_exists('\\Pho\\Kernel\\Kernel')) {
            throw new \InvalidArgumentException('Kernel class not founded in current path:' . $kernel_path);
            return;
        }
        
        $configs = array(
          "services"=>array(
                "database" => getenv('DATABASE_URI'),
                "storage" => getenv("STORAGE_URI"),
          ),
          "default_objects" => array(
                "graph" => class_exists(getenv('DEFAULT_GRAPH_CLASS')) ? getenv('DEFAULT_GRAPH_CLASS') : class_exists(\PhoNetworksAutogenerated\Twitter::class) ? \PhoNetworksAutogenerated\Twitter::class : ( class_exists(\PhoNetworksAutogenerated\Facebook::class) ? \PhoNetworksAutogenerated\Facebook::class : \PhoNetworksAutogenerated\Graph::class ),
                "founder" => class_exists(getenv('DEFAULT_GRAPH_CLASS')) ? getenv('DEFAULT_GRAPH_CLASS') : User::class,
          )
        );

        $this->kernel = new \Pho\Kernel\Kernel($this->config);
        $this->founder = new \PhoNetworksAutogenerated\User($this->kernel, $this->kernel->space(), $input->getOption('password'));
        $this->kernel->boot($this->founder);


        $this->server = new \Pho\Server\Rest\Daemon($this->kernel);
        $this->server->setPort(1337);
        //eval(\Psy\sh());
        $this->server->serve($input->getOption('port'), $input->getOption('host'));
    }
}
{'fraction_non_alphanumeric': 0.14041948098115892, 'fraction_numerical': 0.0014219694276573053, 'mean_word_length': 3.025035765379113, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 67, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5804330', 'n_tokens_mistral': 1666, 'n_tokens_neox': 1583, 'n_words': 302}