Giter Club home page Giter Club logo

basecommandbundle's People

Contributors

johanmeiring avatar mostertb avatar pierredup avatar sarelvdwalt avatar syb3r1us avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

basecommandbundle's Issues

Fix Travis CI build for HHVM

Currently fails as follows

$ if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then phpenv config-rm xdebug.ini; fi;
File xdebug.ini does no exist.
The command "if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then phpenv config-rm xdebug.ini; fi;" failed and exited with 1 during .

Presumably due to the TRAVIS_PHP_VERSION not matching the specific version of HHVM added in #26

PostRun Done Hook

It would be cool to have a function that the BaseCommand will always call via it's destructor - as the first act. This can be used to say "hey, will you please SMS me when you're done?"

We can later on build some strategies around this, so we can call our commands with something like:
--done-sms=0821231234
--done-email=[email protected]
--done-task-complete

Move initialize phase to event listeners

Based on the feedback on #11, this issue is to start a discussion on how to handle the initialize method on the BaseCommand, so that a user doesn't have to worry to call the parent method.

I think this would be a bit more difficult to handle than the input definition.
The main difficulties currently is the tight coupling on the container and the RuntimeConfig.

One option is to move the initialisation of the RuntimeConfig into an event listener with a very high priority (so it should also be called first before any other listeners). In that event we can set the container parameters as well as the values from the input, then have a setter on the BaseCommand where the runtime config can be injected. I'm not sure if this is the most optimal solution, but currently I'm unsure of another way to approach this.

Strategies for Logfile Names

Currently the logfile name can either be specified manually or will be generated from the name of the file in which the command is defined.

It would be nice to offer other automatic naming algorithms. This issue is for creating the framework for different naming algorithms to be interchanged. A GoF Strategy Pattern may be a good solution here.

An example of another simple algorithm might be one extends the current one but appends the name of the host on which the log originated.

Tasks:

  • Framework for switching out algorithm
  • Configuration for user to specify which algortihm they wish to use
  • Implement another example algorithm to prove the system
  • Integrate with Logfile Extension functonality

Clear Test App Cache Prior to TestSuite

The cache of the bundled Symfony Application is not cleared in between executions of the PHPUnit test suite. This sometimes causes false positives on test failures (particularly when modifying code that affects Dependency Injection).

Clearing and warming up the Symfony cache is, however, very slow so we should avoid doing this is a setUp() or setUpBeforeClass(). The best option would be if it could be done once per execution of the phpunit.

A potential solution could be to define our own autoloading file that first calls the composer autoloader and then does the cache clear. A console entrypoint has already been added to help with this

Unhandled Exception Listener

Problem: When a command is being run in the background (such as via cron), there is no indication that the execution we terminated early due to an unhandled exception. Symfony outputs an error to the terminal however, in many cases this output is ignored in favour of log files when executing in such an automated background fashion.

Solution: Add a kernel listener for the console.exception event that attempts to log the exception to a logfile if it was thrown by a command that extends BaseComand (using the command's own logger)

We already have something like this in the internal Afrihost codebase:

 public function onConsoleException(ConsoleExceptionEvent $event)
    {
        // If the command is a subclass of AHCommandBase, try log the exception to the command's log file
        if($event->getCommand() instanceof AHCommandBase){
            try{
                /* @var $command AHCommandBase */
                $command = $event->getCommand();
                $exception = $event->getException();

                $message = 'Uncaught Exception Encountered! Message: '.$exception->getMessage().PHP_EOL.
                    'File: '.$exception->getFile().PHP_EOL.
                    'Line: '.$exception->getLine().PHP_EOL;
                $command->getLogger()->addEmergency($message);
                $command->getLogger()->addInfo('Trace: '.$exception->getTraceAsString());
            } catch(\Exception $e){
                // do nothing if logging throws further exception
            }
        }
    }

This just needs to be incorporated in to the BaseCommandBundle so that:

  • The listener is an opt in feature (so that we are not forcing everyone's kernel to be clogged up with our listener)
  • The log level of the log entry can be defined in config
  • Something is done about making the log entry format more compatible. Not everyone likes to have erroneous newline characters in their log files (this breaks parsing)

The last task is probably a 'nice to have'

Bundle Config for Default Log Level

Currently if the log level is not specified explicitly for a command using setLogLevel() or the --log-level parameter, the default level is WARNING.

It would be nice for this default to be able to be specified in the applications config.yml so that users can have different default values between development, staging and production environments

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.