• Out of all of the MVC solutions for WP, this by far seems to be the most well documented, and I’d love to give it a spin.

    Unfortunately, the code generation utility is failing silently for me. I’m running the default path, and when I tried adding print_r($argv) to the top of core/wpmvc.php, I saw the args correctly passed, as well as a fatal error:headers already passed (so I know it’s loading the wp environment.)

    I’ve tried setting my plugins dir to 777 to ensure it’s not a permissions thing and no luck.

    Running Ubuntu 11.10 if that matters. Any insight is gily appreciated.

    http://wordpress.org/extend/plugins/wp-mvc/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Brian Zeligson

    (@beezeee)

    If it helps, when I hack wpmvc.php to accept $_GET[‘argv’] and visit http://localhost/wp-content/plugins/wp-mvc/core/wpmvc.php?argv%5B%5D=caller&argv%5B%5D=generate&argv%5B%5D=plugin&argv=test in my browser, here’s the output:

    Welcome to WP MVC Console! Sorry, a shell named “e_shell” couldn’t be found in any of the MVC plugins. Please make sure a shell class exists in “app/shells/e_shell.php”, or execute “./wpmvc” to see a list of available shells.

    Additionally, visiting http://localhost/wp-content/plugins/wp-mvc/core/wpmvc.php outputs

    Welcome to WP MVC Console! Available Shells: Core Destroy Generate Help To get information about a shell try: wpmvc help shell

    and register_argc_argv is on.

    No output at the terminal at all…

    Thread Starter Brian Zeligson

    (@beezeee)

    Fixed!

    Added the following right before the include statement –

    $_SERVER = array(
    “HTTP_HOST” => “localhost”,
    “SERVER_NAME” => “localhost”,
    “REQUEST_URI” => “/”,
    “REQUEST_METHOD” => “GET”
    );

    thanks to info found here – http://vocecommunications.com/blog/2011/03/running-wordpress-from-command-line/

    I’d suspect this works on any setup, but I haven’t tested anywhere other than my local (should be localhost no matter what though, even if over ssh.)

    In the case that’s correct, the author might like to add this code to the plugin, and better yet, add me as contributor… 🙂

    I don’t doubt that the command line is working perfectly under Unix but for me it’s a pain under Windows.

    If you’re like me and want to use the command line from your webserver replace the content of wp-mvc/core/wpmvc.php by:

    <?php
    
    //Allow command via html form only for localhost.
    //If you dev on a distant server you might want to add it here
    $allow_html_cmd_for = array('localhost', '127.0.0.1');
    
    $command = null;
    if (isset($argv))
    { //Run from command line
      $command = $argv;
    }
    elseif (in_array($_SERVER['SERVER_ADDR'], $allow_html_cmd_for))
    { //No command line argument, use html form
    
      if (isset($_POST['cmd']))
      { //Process form command
        $command = array(__FILE__);
        $command = array_merge($command, explode(' ', $_POST['cmd']));
      }
    
      //Display html form
    ?>
      <h2>WP-MVC Command line</h2>
      <form action="" method="POST" name="command">
        wpmvc
        <input type="text" name="cmd" size="100" value="<?php echo isset($_POST['cmd']) ? $_POST['cmd'] : '' ?>"/>
        <button type="submit">Run command</button>
      </form>
      <script type="text/javascript">
        //Make the input field behave like a prompt
        input = document.forms['command'].elements['cmd'];
        input.focus();
        input.value = input.value;
      </script>
    <?php
    }
    
    if ($command !== null)
    { //Run command
      $wordpress_path = getenv('WPMVC_WORDPRESS_PATH');
      $wordpress_path = $wordpress_path ? rtrim($wordpress_path, '/').'/' : dirname(__FILE__).'/../../../../';
    
      ob_start();
      require_once $wordpress_path.'wp-load.php';
      $shell = new MvcShellDispatcher($command);
    
      $lines = ob_get_contents();
      ob_end_clean();
    
      if (isset($argv))
        echo $lines."\n";
      else
        echo nl2br(preg_replace('/\[[0-9,;]*m/U', '', $lines));
    }
    ?>

    You can then access the form from your browser at something like: http://127.0.0.1/wp-content/plugins/wp-mvc/core/wpmvc.php

    Error won’t display pretty because of the die() in the subfunctions but at least it’ll let you generate your plugin without having to dig in your php installation in case the command line isn’t working!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: WP MVC] Code generation fails silently’ is closed to new replies.