-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from itmundi/install_craft
Install Craft when its not installed yet
- Loading branch information
Showing
30 changed files
with
901 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
namespace Craft; | ||
|
||
/** | ||
* Schematic Behavior. | ||
* | ||
* Sync Craft Setups. | ||
* | ||
* @author Nerds & Company | ||
* @copyright Copyright (c) 2015, Nerds & Company | ||
* @license MIT | ||
* | ||
* @link http://www.nerds.company | ||
*/ | ||
class SchematicBehavior extends AppBehavior | ||
{ | ||
// Properties | ||
// ========================================================================= | ||
|
||
/** | ||
* @var | ||
*/ | ||
private $_isInstalled; | ||
|
||
/** | ||
* Determines if Craft is installed by checking if the info table exists. | ||
* | ||
* @return bool | ||
*/ | ||
public function isInstalled() | ||
{ | ||
if (!isset($this->_isInstalled)) { | ||
try { | ||
// First check to see if DbConnection has even been initialized, yet. | ||
if (craft()->getComponent('db')) { | ||
// If the db config isn't valid, then we'll assume it's not installed. | ||
if (!craft()->getIsDbConnectionValid()) { | ||
return false; | ||
} | ||
} else { | ||
return false; | ||
} | ||
} catch (\Exception $e) { | ||
return false; | ||
} | ||
|
||
$this->_isInstalled = craft()->db->tableExists('info', false); | ||
} | ||
|
||
return $this->_isInstalled; | ||
} | ||
|
||
/** | ||
* Tells Craft that it's installed now. | ||
*/ | ||
public function setIsInstalled() | ||
{ | ||
// If you say so! | ||
$this->_isInstalled = true; | ||
} | ||
|
||
/** | ||
* Schematic requires the pro edition. | ||
* | ||
* @return string | ||
*/ | ||
public function getEdition() | ||
{ | ||
return Craft::Pro; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
defined('CRAFT_BASE_PATH') || define('CRAFT_BASE_PATH', __DIR__.'/../../../../craft/'); | ||
defined('CRAFT_APP_PATH') || define('CRAFT_APP_PATH', CRAFT_BASE_PATH.'app/'); | ||
defined('CRAFT_CONFIG_PATH') || define('CRAFT_CONFIG_PATH', CRAFT_BASE_PATH.'config/'); | ||
defined('CRAFT_PLUGINS_PATH') || define('CRAFT_PLUGINS_PATH', CRAFT_BASE_PATH.'plugins/'); | ||
defined('CRAFT_STORAGE_PATH') || define('CRAFT_STORAGE_PATH', CRAFT_BASE_PATH.'storage/'); | ||
defined('CRAFT_TEMPLATES_PATH') || define('CRAFT_TEMPLATES_PATH', CRAFT_BASE_PATH.'templates/'); | ||
defined('CRAFT_TRANSLATIONS_PATH') || define('CRAFT_TRANSLATIONS_PATH', CRAFT_BASE_PATH.'translations/'); | ||
defined('CRAFT_ENVIRONMENT') || define('CRAFT_ENVIRONMENT', 'console'); | ||
|
||
/* | ||
* Yii command line script file configured for Craft. | ||
*/ | ||
|
||
// fix for fcgi | ||
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); | ||
|
||
ini_set('log_errors', 1); | ||
ini_set('error_log', CRAFT_STORAGE_PATH.'runtime/logs/phperrors.log'); | ||
|
||
error_reporting(E_ALL & ~E_STRICT); | ||
ini_set('display_errors', 1); | ||
defined('YII_DEBUG') || define('YII_DEBUG', false); | ||
defined('YII_TRACE_LEVEL') || define('YII_TRACE_LEVEL', 3); | ||
|
||
require_once CRAFT_APP_PATH.'framework/yii.php'; | ||
require_once CRAFT_APP_PATH.'Craft.php'; | ||
require_once CRAFT_APP_PATH.'Info.php'; | ||
|
||
// Guzzle makes use of these PHP constants, but they aren't actually defined in some compilations of PHP. | ||
// See http://it.blog.adclick.pt/php/fixing-php-notice-use-of-undefined-constant-curlopt_timeout_ms-assumed-curlopt_timeout_ms/ | ||
defined('CURLOPT_TIMEOUT_MS') || define('CURLOPT_TIMEOUT_MS', 155); | ||
defined('CURLOPT_CONNECTTIMEOUT_MS') || define('CURLOPT_CONNECTTIMEOUT_MS', 156); | ||
|
||
// Load up Composer's files | ||
require CRAFT_APP_PATH.'vendor/autoload.php'; | ||
require __DIR__.'/../../../autoload.php'; | ||
|
||
// Disable the PHP include path | ||
Yii::$enableIncludePath = false; | ||
|
||
// Because CHttpRequest is one of those stupid Yii files that has multiple classes defined in it. | ||
require_once CRAFT_APP_PATH.'framework/web/CHttpRequest.php'; | ||
|
||
// Fake server name on cli | ||
$_SERVER['SERVER_NAME'] = getenv('CRAFT_SITENAME'); | ||
|
||
// Include our console app | ||
require_once __DIR__.'/../consolecommands/SchematicConsoleApp.php'; | ||
|
||
Yii::setPathOfAlias('app', CRAFT_APP_PATH); | ||
Yii::setPathOfAlias('plugins', CRAFT_PLUGINS_PATH); | ||
|
||
$app = Yii::createApplication('Craft\SchematicConsoleApp', CRAFT_APP_PATH.'etc/config/console.php'); | ||
$app->run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Craft; | ||
|
||
/** | ||
* Schematic Export Command. | ||
* | ||
* Sync Craft Setups. | ||
* | ||
* @author Nerds & Company | ||
* @copyright Copyright (c) 2015, Nerds & Company | ||
* @license MIT | ||
* | ||
* @link http://www.nerds.company | ||
*/ | ||
class ExportCommand extends BaseCommand | ||
{ | ||
/** | ||
* Exports the Craft datamodel. | ||
* | ||
* @param string $file file to write the schema to | ||
* | ||
* @return int | ||
*/ | ||
public function actionIndex($file = 'craft/config/schema.yml') | ||
{ | ||
craft()->schematic->exportToYaml($file); | ||
|
||
Craft::log(Craft::t('Exported schema to {file}', array('file' => $file))); | ||
|
||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace Craft; | ||
|
||
/** | ||
* Schematic Import Command. | ||
* | ||
* Sync Craft Setups. | ||
* | ||
* @author Nerds & Company | ||
* @copyright Copyright (c) 2015, Nerds & Company | ||
* @license MIT | ||
* | ||
* @link http://www.nerds.company | ||
*/ | ||
class ImportCommand extends BaseCommand | ||
{ | ||
/** | ||
* Imports the Craft datamodel. | ||
* | ||
* @param string $file yml file containing the schema definition | ||
* @param string $override_file yml file containing the override values | ||
* @param bool $force if set to true items not in the import will be deleted | ||
* | ||
* @return int | ||
*/ | ||
public function actionIndex($file = 'craft/config/schema.yml', $override_file = 'craft/config/override.yml', $force = false) | ||
{ | ||
if (!IOHelper::fileExists($file)) { | ||
$this->usageError(Craft::t('File not found.')); | ||
} | ||
|
||
$result = craft()->schematic->importFromYaml($file, $override_file, $force); | ||
|
||
if (!$result->hasErrors()) { | ||
Craft::log(Craft::t('Loaded schema from {file}', array('file' => $file))); | ||
|
||
return 0; | ||
} | ||
|
||
Craft::log(Craft::t('There was an error loading schema from {file}', array('file' => $file))); | ||
print_r($result->getErrors()); | ||
|
||
return 1; | ||
} | ||
} |
Oops, something went wrong.