huantime/laravel-cms

此包已被弃用且不再维护。未建议替换包。

适用于任何现有或新Laravel网站的简单Bootstrap Laravel CMS。只需添加少量带前缀的数据库表,不会影响现有的数据库表。支持Laravel 5和Laravel 6。Amila Laravel CMS

1.3.0 2019-10-18 06:11 UTC

README

Amila Laravel CMS

image Laravel CMS image Latest Stable Version

  • 免费、开源的简单Bootstrap Laravel CMS,适用于任何现有Laravel 5.x或新Laravel 6网站。
  • 只需添加少量带前缀的数据库表,不会影响现有的数据库表。
  • 您可以轻松自定义数据库表名、页面URL路径(路由)和模板(主题)
  • 安装后网站即可使用。易于使用,简单但灵活。
  • 基本Laravel 5.x/Laravel 6.x语法和blade模板,无需学习新的“语言”

如何安装和卸载(支持Laravel 5.x和Laravel 6.x)

// Make sure you already configured the database in the .env
// Go to the laravel project folder and install it via composer
// Initialize the CMS (You can set up database table prefix and locale here)

composer require alexstack/laravel-cms && php artisan laravelcms


// Now you can access the cms frontend site: http://yourdomain/cms-home

// Access the backend with the FIRST USER of your site: http://yourdomain/cmsadmin

// Uninstall the CMS
php artisan laravelcms --action=uninstall

演示和文档

安装命令输出截图

image

卸载命令输出截图

image

管理面板截图

image image image

将区域语言设置为cn而不是en

cn_image

访问后端/cmadmin/时出现错误 "路由 [login] 未定义"

  • 这意味着您尚未安装Laravel Auth
  • 可以通过以下命令修复
// Laravel 5.x
php artisan make:auth && php artisan migrate
// Laravel 6.x
composer require laravel/ui && php artisan ui vue --auth

如何登录到后端/cmadmin/ ?

  • Amila CMS使用您现有的Laravel用户系统
  • 您需要使用站点的第一个用户(user_id = 1)进行登录
  • 您可以通过更改config/laravel-cms.php中的admin_ary来添加更多管理员用户
  • 如果您没有任何现有用户,则可以通过http://your-domain/register注册一个新用户

为什么上传的图片无法显示(404错误)

  • 您可以创建一个存储公共链接来修复它
  • php artisan storage:link
  • 例如,public/storage应该链接到../storage/app/public,如果public/storage是一个真实的文件夹,您应该将其删除/重命名,并运行"php artisan storage:link"来设置链接。

在config/laravel-cms.php中自定义CMS路由

  • homepage_route:这是前端主页。默认为/cmshome,您可以将它更改为/,然后在routes/web.php中删除现有的/路由
# Change homepage_route to /  in config/laravel-cms.php
'homepage_route'    => env('LARAVEL_CMS_HOMEPAGE_ROUTE', '/'),

# Remove the existing / route in the routes/web.php

// Route::get('/', function () {
//     return view('welcome');
// });
  • page_route_prefix:这是前端页面前缀。默认为/cmshome,它会匹配/cmshome*这样的路径。您可以将它更改为如/xxx/这样的文件夹或任何如xxx-这样的格式,例如:Page- Article-
'page_route_prefix' => env('LARAVEL_CMS_PAGE_PREFIX', '/Article-'),
  • admin_route:这是后端管理页面路由,默认为/cmshome
'admin_route'       => env('LARAVEL_CMS_BACKEND_ROUTE', '/admin2019'),
  • 更改路由后,您需要运行以下命令
php artisan laravelcms --action=clear

在前端Laravel .blade.php模板文件中显示不同大小的图片

  • .blade.php代码示例
@if ( isset($file_data->main_image) )
    <img src="{{$helper->imageUrl($file_data->main_image, '1000') }}" class="img-fluid" />

    <img src="{{$helper->imageUrl($file_data->main_image, '500') }}" class="img-fluid" />

    <img src="{{$helper->imageUrl($file_data->main_image, 'w', '150') }}" class="img-fluid" />

    <img src="{{$helper->imageUrl($file_data->main_image, '100', '100') }}" class="img-fluid" />

    <img src="{{$helper->imageUrl($file_data->main_image, 'original', 'original') }}" class="img-fluid" />

@endif
  • 您可以获取任何宽度和高度的图片,或使用原始图片。
  • 可用图片变量:$file_data->main_image, $file_data->main_banner, $file_data->extra_image, $file_data->extra_image_2
  • CMS将在第一次调整图片大小后,之后直接使用。

如何更改前端的CSS & JS资源?

  • 资产文件位于public/laravel-cms/<主题名称>,例如:public/laravel-cms/frontend/css
  • 加载CSS或JS的示例代码
<link rel="stylesheet" href="{{ $helper->assetUrl('css/main.css') }}">
...
<script src="{{ $helper->assetUrl('js/bottom.js') }}"></script>
  • 默认模板文件将使用last_modify_time参数加载CSS和JS资产,以避免浏览器缓存

如何从默认主题设置不同的模板主题?

  • 将默认主题文件夹/resources/views/laravel-cms/frontend复制到/resources/views/laravel-cms/new_theme
  • 在设置页面中将frontend_dir更改为new_theme
  • config/laravel-cms.php中的默认值
    'template' => [
        'frontend_dir'      => 'frontend',
        'backend_dir'       => 'backend',
        'backend_language'  => 'en',
        'frontend_language' => 'en',
    ]
  • 运行php artisan config:cache以加载新配置文件
  • 在后台更改页面的模板设置
  • CSS/JS资产文件将位于public/laravel-cms/new_theme

如何在config/laravel-cms.php中设置页面SEO URL的默认slug格式和后缀?

  • 您可以在设置页面中更改它
  • 'slug_format'可以是from_title, id, pinyin
  • 'slug_suffix'可以是您想要的任何内容,空表示无后缀
    'slug_format'   => 'from_title',
    'slug_suffix'   => '.html',
    'slug_separate' => '-',

如何设置全新的Laravel 6.x网站并安装我们的CMS?

  • 这对于本地测试很有用
// Install Laravel 6.x & the CMS package
composer create-project --prefer-dist laravel/laravel cms && cd cms && composer require alexstack/laravel-cms

// Then you need to change the database settings in the .env, after that initialize CMS
cd cms & vi .env
php artisan laravelcms

// Or initialize the CMS with silent mode
php artisan laravelcms --action=initialize --locale=en --table_prefix=cms_  --silent=yes

// Enable auth system for Laravel 6.x
composer require laravel/ui && php artisan ui vue --auth && php artisan migrate

// Config the document root to point to the cms/public then you can access the backend
// Tips: You will need register a new user, the first user will be the admin user

如何升级CMS?

  • 在您的Laravel项目文件夹中运行以下命令
  • 它将询问您是否要将新的视图、资产和语言文件复制到项目中
composer require alexstack/laravel-cms && php artisan laravelcms --action=upgrade
  • 升级截图

image

许可

  • Amila Laravel CMS是开源软件,根据MIT许可证授权。