Upgrade Guide

Upgrade Guide

This guide will point out the key points to be aware of when upgrading to version 3.

All classes within the app directory have a new namespace of App, controllers and models/modules have the following namespaces for classes placed directly in those directories.

Controllers

namespace App\Controllers;

Models

namespace App\Models;

Modules

namespace App\Controllers\ModuleName;

Instantiating a model

Models are instantiated typically within a construct method, use the full namespace to call the class:

public function __construct() { parent::__construct(); $this->model = new \App\Models\ModelName(); }

Views

Views like classes should have filenames starting with a capital letter for both the directory and the file, for instance welcome/index.php becomes Welcome/Index.php.

View::render('Welcome/Index', $data);

Loading Images, css, js and assets

Nova has been designed to live above the document root as such images and other assets cannot be called directly instead they need to be routed from Nova, this is done by calling Url::resourcePath().

By default this will return the path to the assets folder, place general assets in there. For theme files place them inside the Theme/Assets directory and call them by using Url::templatePath() this loads the path to the default template.

Make use of the Assets helper to load the css files:

Assets::css([ 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css', Url::templatePath().'css/style.css' ]);

An example of loading an image from Default/Assets/images.

<img src='<?=Url::templatePath();?>images/nova.png' alt='<?=SITETITLE;?>'>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值