Skip to content

Commit e083bdf

Browse files
committed
Add rewriteConfig() and invoke twice incase unexpect failure
1 parent be6cd43 commit e083bdf

File tree

3 files changed

+32
-16
lines changed

3 files changed

+32
-16
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ composer require alexstack/laravel-cms && php artisan laravelcms
3434

3535
```php
3636
// Step 1: Install Laravel to folder cms
37-
composer create-project --prefer-dist laravel/laravel cms && cd cms && composer require alexstack/laravel-cms
37+
composer create-project laravel/laravel cms && cd cms && composer require alexstack/laravel-cms
3838

3939
// Step 2: Change the database connection settings in the .env
40-
cd cms & vi .env
40+
vi .env // change DB_DATABASE, DB_USERNAME, DB_PASSWORD
4141

42-
// Step 3: install cms
43-
php artisan laravelcms
42+
// Step 3: install CMS
43+
php artisan laravelcms  --silent=yes
4444

4545
// Step 4: Enable Laravel auth/login system
4646
composer require laravel/ui && php artisan ui bootstrap --auth && php artisan migrate

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"name": "alexstack/laravel-cms",
3-
"description": "Simple Bootstrap Laravel CMS. Can integrate to any existing Laravel project. Only add few database tables with prefix, not effect your existing database tables. Support Laravel 7.x & Laravel 6.x & Laravel 5.x - Amila Laravel CMS",
3+
"description": "Simple Bootstrap Laravel CMS. Can integrate to any existing Laravel project. Only add few database tables with prefix, not effect your existing database tables. Support Laravel 8.x & 7.x & Laravel 6.x & Laravel 5.x - Amila Laravel CMS",
44
"type": "library",
55
"homepage": "https://github.com/AlexStack/Laravel-CMS/",
6-
"keywords": ["laravel", "laravel cms", "laravel blog", "laravel wordpress", "LaravelCMS", "amila laravel cms", "php cms", "cms", "laravel 6", "laravel6", "laravel 7", "laravel7", "Amila CMS", "headless cms", "existing laravel project"],
6+
"keywords": ["laravel", "laravel cms", "laravel blog", "laravel wordpress", "LaravelCMS", "amila laravel cms", "php cms", "cms", "laravel 6", "laravel6", "laravel 7", "laravel7", "Amila CMS", "headless cms", "existing laravel project", "laravel 8"],
77
"license": "MIT",
88
"support": {
99
"issues": "https://github.com/AlexStack/Laravel-CMS/issues"

src/Console/Commands/LaravelCMS.php

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -334,16 +334,17 @@ public function initializeCms($options)
334334
'--provider' => 'AlexStack\LaravelCms\LaravelCmsServiceProvider',
335335
]);
336336

337-
if ('cms_' != $table_prefix || 'en' != $app_locale) {
338-
$config_str = str_replace(
339-
["=> 'cms_", "=> 'en"],
340-
["=> '".$table_prefix, "=> '".$app_locale],
341-
file_get_contents(dirname(__FILE__, 3).'/config/laravel-cms.php')
342-
);
343-
$config_str = trim($config_str); // in case it not change in ram memory
344-
file_put_contents(base_path('config/laravel-cms.php'), $config_str);
345-
$this->line('<fg=cyan>----> Changed db table prefix to : </><fg=yellow>'.$table_prefix.'</>');
346-
}
337+
// if ('cms_' != $table_prefix || 'en' != $app_locale) {
338+
// $config_str = str_replace(
339+
// ["=> 'cms_", "=> 'en"],
340+
// ["=> '".$table_prefix, "=> '".$app_locale],
341+
// file_get_contents(dirname(__FILE__, 3).'/config/laravel-cms.php')
342+
// );
343+
// $config_str = trim($config_str); // in case it not change in ram memory
344+
// file_put_contents(base_path('config/laravel-cms.php'), $config_str);
345+
// $this->line('<fg=cyan>----> Changed db table prefix to : </><fg=yellow>'.$table_prefix.'</>');
346+
// }
347+
$this->rewriteConfig($table_prefix, $app_locale);
347348

348349
$this->call('config:cache');
349350
$this->call('route:clear');
@@ -371,6 +372,8 @@ public function initializeCms($options)
371372

372373
$this->forBrandNewProject();
373374

375+
$this->rewriteConfig($table_prefix, $app_locale); // incase something wrong
376+
374377
$this->clearCache($options);
375378

376379
// success message
@@ -466,4 +469,17 @@ public function forBrandNewProject(){
466469
$this->copyCmsFiles($source_files, $target_dir, $backup_dir, $ignore_files);
467470
}
468471
}
472+
473+
public function rewriteConfig($table_prefix, $app_locale){
474+
if ('cms_' != $table_prefix || 'en' != $app_locale) {
475+
$config_str = str_replace(
476+
["=> 'cms_", "=> 'en"],
477+
["=> '".$table_prefix, "=> '".$app_locale],
478+
file_get_contents(dirname(__FILE__, 3).'/config/laravel-cms.php')
479+
);
480+
$config_str = trim($config_str); // in case it not change in ram memory
481+
file_put_contents(base_path('config/laravel-cms.php'), $config_str);
482+
$this->line('<fg=cyan>----> Changed db table prefix to : </><fg=yellow>'.$table_prefix.'</>');
483+
}
484+
}
469485
}

0 commit comments

Comments
 (0)