Title: [Plugin: WP MVC] Code generation fails silently
Last modified: August 20, 2016

---

# [Plugin: WP MVC] Code generation fails silently

 *  [Brian Zeligson](https://wordpress.org/support/users/beezeee/)
 * (@beezeee)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/plugin-wp-mvc-code-generation-fails-silently/)
 * 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/](http://wordpress.org/extend/plugins/wp-mvc/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [Brian Zeligson](https://wordpress.org/support/users/beezeee/)
 * (@beezeee)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/plugin-wp-mvc-code-generation-fails-silently/#post-2629048)
 * 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](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:
 * [35;1m[4mWelcome to WP MVC Console![0m[0m 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](http://localhost/wp-content/plugins/wp-mvc/core/wpmvc.php)
   outputs
 * [35;1m[4mWelcome to WP MVC Console![0m[0m Available Shells: Core [1mDestroy[
   0m [1mGenerate[0m [1mHelp[0m 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](https://wordpress.org/support/users/beezeee/)
 * (@beezeee)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/plugin-wp-mvc-code-generation-fails-silently/#post-2629055)
 * 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/](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… 🙂
 *  [dodmax](https://wordpress.org/support/users/dodmax/)
 * (@dodmax)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/plugin-wp-mvc-code-generation-fails-silently/#post-2629358)
 * 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](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.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-mvc_ffffff.svg)
 * [WP MVC](https://wordpress.org/plugins/wp-mvc/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-mvc/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-mvc/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-mvc/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-mvc/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-mvc/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [dodmax](https://wordpress.org/support/users/dodmax/)
 * Last activity: [13 years, 11 months ago](https://wordpress.org/support/topic/plugin-wp-mvc-code-generation-fails-silently/#post-2629358)
 * Status: not resolved