background preloader

Yii Framework

Facebook Twitter

Yii2 Pjax Tutorial - Neat Tutorials Blog. Pjax is a jQuery plugin that allows quick website navigation by combining ajax and pushState.

Yii2 Pjax Tutorial - Neat Tutorials Blog

It works by sending a special request to the server every time a link is clicked or a form is submitted. The server sends back the content that needs to be updated, pjax replaces old content with new content and pushes the new URL to browser history, without the need to update the whole page. Yii2 framework has a Pjax widget that helps you pjaxify your website in just one easy step. Add one line in the beginning of your view. <? Yii2 Assets Management.

I always thought Yii Assets Management was way complex than the framework's other features and Yii2 has not changed my opinion much.

Yii2 Assets Management

Regardless, it is a very handy feature and any one building a project with some complex dependencies will thank the Yii2 team for this. Yii2 requires you to group your assets into bundles by using AssetBundle class. Write & use a custom Component in Yii2.0. This is a simple example in Yii2.0 to understand how you can write a custom component and use it inside your app.

Write & use a custom Component in Yii2.0

(basic template) Step1:Make a folder named "components" in your project root folder. step2: write your custom component inside components folder eg:MyComponent.php namespace app\components; use Yii; use yii\base\Component; use yii\base\InvalidConfigException; class MyComponent extends Component{ public function welcome() { echo "Hello..Welcome to MyComponent"; } } Yii2 Framework. Kartik-v/yii2-money. Tutorial about How to Integrate Yii2 with fantastic theme AdminLTE. Yii2 comes with a charming twitter bootstrap version 3.

Tutorial about How to Integrate Yii2 with fantastic theme AdminLTE

But if it is less, then you can integrate with web templates that you like. One example is wonderfull template "adminLTE" You can use ready-skeleton on GitHub also. With Yii2 we can do it easily, the following steps. Yii 2.0 URL Creation. Yii 2.0 having the url manager to handle and create urls in different way.

Yii 2.0 URL Creation

The URL manager is a built-in application component named urlManager. We can access this component in web and console application via \Yii::$app->urlManager and it is available in framework by default. We can use use yii\helpers\Url; namespace. URL creation using Namespace In Yiiframework 2.0 Dont forget to add the below namespace It will helpful to create simple URLs. Tutorial about How to Integrate Yii2 with fantastic theme AdminLTE. Php - How to get user role in Yii2? Krajee Yii Extensions - © Kartik. I Love Yii.

String Generator. Hide or remove basic/web from URL in Yii 2.0. Yii is an awesome framework that does many things automatically.

Hide or remove basic/web from URL in Yii 2.0

As you know, the default installation of Yii App makes site accessible via URL ‘ or something like this but in a production server you may wish to hide or remove basic/web from URL in Yii 2.0 as well as access it with SEO friendly URL (‘ In a VPS or dedicated hosting environment, there is no problem to set ‘basic/web‘ as the document root and apply Recommended Apache Configuration as in described by Yii 2.0 official documentation because you have access to virtual host configuration or Apache’s ‘httpd.conf‘ file. But in shared or reseller hosting environment, you are often quite limited about configuration and directory structure so you can’t change the document root.

Creating SEO friendly URL in Yii 2.0 framework. Yii 2.0 framework has a major improvement over version 1.1.

Creating SEO friendly URL in Yii 2.0 framework

Creating SEO friendly URL in Yii 2.0 framework has been a lot easier. All is just turning pretty url ‘on‘ to your Yii application and writing very few rewrite rules in htaccess file, enough to hide index.php from your URL and to make them SEO friendly. At the time to writing the post the Yii framework version 2.0 Beta has been released and I have used default installation to let these seo friendly URL work on local development server at port 8080. Follow this two steps article to turn pretty urls on. Step 1: Define component in your config file After successful installation of Yii, you can see application home page as given: If you click on About link to visit about page in your site, your browser url will have index.php and get parameters according to path of your installation: REST API Tutorial. Yii-debug-toolbar. A configurable set of panels that display various debug information about the current request/response.

yii-debug-toolbar

The Yii Debug Toolbar is a configurable set of panels that display various debug information about the current request/response and when clicked, display more details about the panel's content. It is a ported to PHP famous Django Debug Toolbar. Currently, the following panels have been written and are working: Request timerA list of superglobalsApplication settingsSQL queries including time to execute and param bindingsLogging output via Yii built-in logging Requirements ¶ JavaScript enabled browser Yii 1.1.4 + Installation ¶

Bsourcecode Programming Blog. Date validation in Yii. How to upload image(photo), and path entry in database with update functionality. I saw many posts that community newbie is confuse in image/photo upload with random name. so I post this topic covering all useful things regarding to image/photo upload(not covering image attribute related functionality) View : ¶ _form.php file: .. 'htmlOptions' => array( 'enctype' => 'multipart/form-data', ), ... .. .. ..

How to upload image(photo), and path entry in database with update functionality

<div class="row"><? Model : ¶ just add below line in rules() method in Model array('image', 'file','types'=>'jpg, gif, png', 'allowEmpty'=>true, 'on'=>'update'), for all others rules you had to give scenario for insert and update as the rule will apply on both page( Insert and Update ) i.e: How to use a single form to collect data for two or more models? Assume we want to use a single HTML form to collect input for both model A and model B, and we want to display input errors (if any) in the same error summary box.

How to use a single form to collect data for two or more models?

We can define the following action code: public function actionCreate(){ $a=new A; $b=new B; if(isset($_POST['A'], $_POST['B'])) { $a->attributes=$_POST['A']; $b->attributes=$_POST['B']; $valid=$a->validate(); $valid=$b->validate() && $valid; if($valid) { $a->save(false); $b->save(false); } } $this->render('create', array( 'a'=>$a, 'b'=>$b, )); }

Implementing cron jobs with Yii. There are two ways to run a cron job: Emulate browser.Run PHP in CLI (console) mode. Emulating browser ¶ This way is a simplest one since you can use existing controller action. Rights-user-preconfigured. I prepackaged Yii Rights / Yii User so you don't have to configure anything but your database info. I prepackaged Yii Rights / Yii User / Yii Private Messaging so you don't have to configure anything but the basics. No hacks, installation, confusion, migrations, configurations, or headaches! Basically, these are downloadable working demos of the three modules. The included instructions with these modules as most of you have figured out, are less than clear at best.

Well, at least to me. I have included 4 working files. These are the modules I packed up. Yii Demo - Cjuidatepicker. Yii - Tutorial. Yii Framework: Best for Web 2.0 Development. Quick Yii API Documentation.