Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install won't run. #2

Open
bsethwalker opened this issue Aug 14, 2013 · 4 comments
Open

Install won't run. #2

bsethwalker opened this issue Aug 14, 2013 · 4 comments

Comments

@bsethwalker
Copy link

After running composer to get everything set-up, I go to the application URL and it outputs a bunch of PHP code into the browser... It looks like it's just printing the entire contents of the Module.php file for the speck-install module. I've copied and pasted what shows up below...

array( 'namespaces' => array( NAMESPACE => DIR . '/src/' . NAMESPACE, ), ), ); } public function getControllerConfig() { return array( 'invokables' => array( 'speck_install' => '\SpeckInstall\Controller\InstallController', ), ); } public function getServiceConfig() { return array( 'factories' => array( 'SpeckInstall\Mapper\Install' => function ($sm) { $mapper = new \SpeckInstall\Mapper\Install; $config = $sm->get('config'); if(isset($config['db'])) { $mapper->setDbAdapter($sm->get('Zend\Db\Adapter\Adapter')); } return $mapper; }, ), ); } public function getConfig() { return array( 'router' => array( 'routes' => array( 'install' => array( 'type' => 'Literal', 'options' => array( 'route' => '/install', 'defaults' => array( 'controller' => 'speck_install', 'action' => 'index', ), ), 'may_terminate' => true, 'child_routes' => array( 'schema' => array( 'type' => 'Literal', 'options' => array( 'route' => '/schema', 'defaults' => array( 'action' => 'schema', ), ), ), ), ), ), ), 'view_manager' => array( 'template_path_stack' => array( DIR . '/view' ), ), ); } public function onBootstrap($e) { if($e->getRequest() instanceof \Zend\Console\Request){ return; } $app = $e->getParam('application'); $em = $app->getEventManager(); $sm = $em->getSharedManager(); $em->attach(MvcEvent::EVENT_DISPATCH, array($this , 'install'), 100); //install event listener $sm->attach('SpeckInstall\Controller\InstallController', 'install.create_tables', function ($e) { return $this->createTables($e, 'SpeckCatalog' ); }); $sm->attach('SpeckInstall\Controller\InstallController', 'install.create_tables', function ($e) { return $this->createTables($e, 'SpeckContact' ); }); $sm->attach('SpeckInstall\Controller\InstallController', 'install.create_tables', function ($e) { return $this->createTables($e, 'ZfcUser' ); }); $sm->attach('SpeckInstall\Controller\InstallController', 'install.create_tables', function ($e) { return $this->createTables($e, 'SpeckAddress' ); }); $sm->attach('SpeckInstall\Controller\InstallController', 'install.create_tables', function ($e) { return $this->createTables($e, 'SpeckCart' ); }); $sm->attach('SpeckInstall\Controller\InstallController', 'install.create_tables', function ($e) { return $this->createTables($e, 'SpeckUserAddress' ); }); $sm->attach('SpeckInstall\Controller\InstallController', 'install.create_tables', function ($e) { return $this->createTables($e, 'SpeckRandomProducts' ); }); //$sm->attach('SpeckInstall\Controller\InstallController', 'install.create_tables', function ($e) { return $this->createTables($e, 'SpeckOrder' ); }); $sm->attach('SpeckInstall\Controller\InstallController', 'install.setup_multisite', array($this, 'setupMultiSite')); $sm->attach('SpeckInstall\Controller\InstallController', 'install.setup_multisite', function ($e) { return $this->createTables($e, 'SpeckMultisite' ); }); $sm->attach('SpeckInstall\Controller\InstallController', 'install.setup_multisite', function ($e) { $name = $e->getParam('website_name'); $query = "insert into website(website_id, name)VALUES(1, '{$name}')"; $e->getParam('mapper')->query($query); return array('true', 'SpeckInstall inserted site name - "' . $name . '"'); }); } public function createTables($e, $moduleName) { $mm = $e->getTarget()->getServiceLocator()->get('modulemanager'); $module = $mm->getModule($moduleName); if(null === $module) { return array(false, 'Missing module - ' . $moduleName . ' - Did you run composer install?'); } $reflection = new \ReflectionClass($module); $path = dirname($reflection->getFileName()); try { $create = file_get_contents($path .'/data/schema.sql'); if(!$create) { throw new \Exception('cannot find schema file'); } $mapper = $e->getParam('mapper'); $mapper->query($create); } catch (\Exception $e) { return array(false, "SpeckInstaller was unable to complete 'createTables' for {$moduleName} - " . $e->getMessage()); } return array(true, "SpeckInstaller ran 'createTables' for {$moduleName}"); } public function setupMultisite($e) { $multisite = $e->getParam('multi_site'); $mm = $e->getTarget()->getServiceLocator()->get('modulemanager'); $module = $mm->getModule('SpeckMultisite'); if(null === $module) { return array(false, 'setup multisite - Missing module - SpeckMultisite - Did you run composer install?'); } $reflection = new \ReflectionClass($module); $path = dirname($reflection->getFileName()); try { $config = include($path .'/config/module.SpeckMultisite.dist.php'); $content = "getMessage()); } return array(true, "stored SpeckMultisite config"); } public function createZfcUserTables($e) { $this->createTables('ZfcUser'); } public function install($e) { if($e->getRouteMatch()->getParam('controller') === 'speck_install') { return; } $response = $e->getResponse(); $response->setStatusCode(307)->getHeaders()->addHeaderLine('Location', '/install'); } }

@bsethwalker
Copy link
Author

I actually found the problem. The opening PHP tag in Module.php was <? instead of <?php

@nclundsten
Copy link
Contributor

You will also need short tags turned on in your php environment, most of
the modules use them in the views/helpers/etc.
Nigel

On Wed, Aug 14, 2013 at 10:00 AM, Brandon Walker
[email protected]:

I actually found the problem. The opening PHP tag in Module.php was <?
instead of <?php


Reply to this email directly or view it on GitHubhttps://github.com//issues/2#issuecomment-22650413
.

@asimsoroya
Copy link

The exact path is .
speck/vendor/speckcommerce/speck-install/Module.php

@UnderDogg
Copy link

After fixing Module.php go to this Url : http://your-vhost/install (if you didn't make a vhost yet, it will go to /install)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants