Skip to content

Commit

Permalink
Fixies and Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
KaduAmaral committed Oct 8, 2017
1 parent a09f7cf commit 38576dd
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 16 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,7 @@ Temporary Items
/.idea/markdown-navigator
/.idea/base.iml
/.idea/blade.xml
/app/example/routes.cache.php

# Application Files
/app/*/routes.cache.php
/app/*/config.php
3 changes: 2 additions & 1 deletion app/example/config.php → app/example/environments/dev.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@


Config::Set([
'url' => 'http://localhost/Base/public_html/',
'url' => 'http://localhost/base/public_html/',
'public' => dirname(dirname(__DIR__)).'/public_html',
'name' => 'example',
]);
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@


Config::Set([
'url' => 'http://localhost/Base/public_html/',
'url' => 'http://localhost/base/public_html/',
'public' => dirname(dirname(__DIR__)).'/public_html',
'name' => 'example',
]);
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@


Config::Set([
'url' => 'http://localhost/Base/public_html/',
'url' => 'http://localhost/base/public_html/',
'public' => dirname(dirname(__DIR__)).'/public_html',
'name' => 'example',
]);
13 changes: 7 additions & 6 deletions base/console/commands/environment.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ public function execute(\CMP\Console $console, $args = []) {
private function setArgs($args) {
$this->app = $args['--app'];
$this->env = $args['--env'];
$this->appPath = APPS.$this->app.DS;
$this->appPath = APPS.$this->app;

}

private function copyConfig() {
$this->console->writeln('Setting config file...');
$path = "{$this->appPath}config.{$this->env}.php";
$path = "{$this->appPath}/environments/{$this->env}.php";
if (file_exists($path))
copy($path, "{$this->appPath}config.php");
copy($path, "{$this->appPath}/config.php");
else
throw new \Exception('Config file does\'t exists for environment '.$this->env);
}
Expand All @@ -50,7 +50,8 @@ private function copyHtaccess() {
if (file_exists($path))
copy($path, $newPath);
else
throw new \Exception('HTACCESS file does\'t exists for environment '.$this->env);
$this->console->writeln("<error>HTACCESS file does\'t exists for environment {$this->env}</error>");
// throw new \Exception('HTACCESS file does\'t exists for environment '.$this->env);
}

private function configure() {
Expand All @@ -62,7 +63,7 @@ private function configure() {

if (is_null($this->config = $this->console->share('config'))) {
$this->config = $this->console->share('config', \Core\Config::SetApplication($this->appPath));
$this->loadFile($this->appPath.'config.php');
$this->loadFile($this->appPath.'/config.php');
}

return TRUE;
Expand All @@ -78,7 +79,7 @@ private function loadFile($file) {
public function getOptionCollection() {
$collection = new \CMP\Command\OptionCollection();
$collection->add('a|app:', 'Application folder name');
$collection->add('e|env:', 'Environment [prod|dev] (default: dev)', 'dev');
$collection->add('e|env:', 'Environment [prod|dev|stage] (default: dev)', 'dev');

return $collection;
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"kaduamaral/connectionpdo": "~1.1",
"phpmailer/phpmailer": "~5.2",
"mobiledetect/mobiledetectlib": "~2.8",
"kaduamaral/cmp": "^1.1"
"kaduamaral/cmp": "^1.1.4"
}
}
2 changes: 1 addition & 1 deletion public_html/.htaccess → public_html/dev.htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Options -Indexes

RewriteEngine On

RewriteBase /Base/public_html/
RewriteBase /base/public_html/

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
Expand Down
5 changes: 1 addition & 4 deletions public_html/index.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);

require_once __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'base'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'loader.php';
require_once dirname(__DIR__).'/base/config/loader.php';

\Core\Application::RUN('example');
22 changes: 22 additions & 0 deletions public_html/prod.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Options +FollowSymlinks

# Prevent Directoy listing
Options -Indexes

# Prevent Direct Access to files
<FilesMatch "(?i)((\.tpl|\.ini|\.log|(?<!robots)\.txt))">
Order deny,allow
Deny from all
</FilesMatch>

RewriteEngine On

RewriteBase /base/public_html/

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^$ index.php?URI=$1 [L,QSA]

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)/? index.php?URI=$1 [L,QSA]
22 changes: 22 additions & 0 deletions public_html/stage.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Options +FollowSymlinks

# Prevent Directoy listing
Options -Indexes

# Prevent Direct Access to files
<FilesMatch "(?i)((\.tpl|\.ini|\.log|(?<!robots)\.txt))">
Order deny,allow
Deny from all
</FilesMatch>

RewriteEngine On

RewriteBase /base/public_html/

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^$ index.php?URI=$1 [L,QSA]

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)/? index.php?URI=$1 [L,QSA]

0 comments on commit 38576dd

Please sign in to comment.