Topic: Yii

PHP Yii Maintenance Mode Tutorial with Examples 0

PHP Yii Maintenance Mode Tutorial with Examples

Today, We want to share with you PHP Yii Maintenance Mode Tutorial with Examples.
In this post we will show you Yii Maintenance Mode, hear for Programming With Yii2: Routing and URL Creation we will give you demo and example for implement.
In this post, we will learn about php – yii toggle maintenance mode ON/OFF with an example.

The Yii Maintenance ModeAny User can simple Display access maintenance Mode or file only View in HTML Page.

  • The Yii Maintenance Controller
  • The Yii Maintence File

The Yii Maintenance Controller

Create or Point the Yii Simple controller main Logix action to page display maintenance mode.

return array(
    'catchAllRequest'=> array('site/yii_maintenance'),
    ............   

The Yii Maintence File

Create or Point the Yii sersver side file to maintenance or processing mode. If the check simple condition here Like PHP functions file_exists() return boolean value false, The PHP Based yii maintenance mode will be simple check switch off or not work.

'catchAllRequest'=>file_exists(dirname(__FILE__).'/.yii_maintenance')? array('site/yii_maintenance') : null,

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about How to implement “Maintenance Mode” in Yii.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

SSL forcefully Redirect HTTP to HTTPS Using .htaccess File 0

SSL forcefully Redirect HTTP to HTTPS Using .htaccess File

Today, We want to share with you SSL forcefully Redirect HTTP to HTTPS Using .htaccess File.In this post we will show you How to force SSL using the .htaccess file , hear for How to redirect HTTP traffic to HTTPS using an .htaccess file we will give you demo and example for implement.In this post, we will learn about Redirecting HTTP to HTTPS Using .htaccess File: Step by Step with an example.

SSL forcefully Redirect HTTP to HTTPS Using .htaccess File

There are the Following The simple About SSL forcefully Redirect HTTP to HTTPS Using .htaccess File Full Information With Example and source code.

As I will cover this Post with live Working example to develop Force your site to load securely with an .htaccess file, so the some Redirect HTTP to HTTPS automatically for this example is following below.

Step 1: first of all simple Editing your .htaccess in main cPanel goto File Manager

Step 2: Sign In to cPanel

Step 3: and then Go to The Files > your File Manager > and Document main Root for:

Step 4: After that choose the tour domain name We want to get access

Step 5: Now a new open tab or window main file opens, look for the name as a .htaccess file.

Step 6: .htaccess redirect http to https

Redirecting HTTP to HTTPS Using .htaccess File

RewriteEngine on

# force ssl
RewriteCond     %{SERVER_PORT} ^80$
RewriteRule     ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

Note: Please get Your .htaccess file and all the Backup your main Data website in case all the something goes wrong.

Redirect All Web Traffic

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.myDomainName.com/$1 [R,L]

Redirect Only a Specific Domain

Simple redirecting a specific main My domain Working on SSL forcefully to use HTTPS

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^myDomainName\.com [NC]
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.myDomainName.com/$1 [R,L]

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about SSL forcefully Redirect HTTP to HTTPS Using .htaccess File.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

How to Get Yii last inserted ID from database 0

How to Get Yii last inserted ID from database

Today, We want to share with you Get Yii last inserted ID.
In this post we will show you Yii get last insert id in controller, hear for Yii get last record id we will give you demo and example for implement.In this post, we will learn about how to get id from database in Yii with an example.

Yii last inserted ID – PHP Yii Framework

Get Yii last inserted ID: If We are working with PHP Based Yii MVC models(from database tables) and run The insert/add operation in Database. We can return the last Yii Functions used to inserted id as below.

Syntax for Yii Get Last Inserted Id

Yii Get Last Inserted Id

$insert_id = Yii::app()->db->getLastInsertID();

Yii get last insert id in Models

PHP Yii Get Last Inserted Id Using Models

if($model->save())
{
    $LastInsertedId = $model->id 
   // this will be get the last inserted id in Yii
}

Get Yii last inserted ID using PDO

$lastInsertedId = Yii::app()->db->getLastInsertId();

yiiframework

This will return the Yii functions last inserted id in the PHP Yii from Database table.

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Yii Get Last Inserted Id.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

PHP Yii Database Connection Tutorial with Examples 0

PHP Yii Database Connection Tutorial with Examples

Today, We want to share with you PHP Yii Database Connection Tutorial with Examples.
In this post we will show you Yii Database Access, hear for php – configuring database connection in Yii framework we will give you demo and example for implement.
In this post, we will learn about Connect To A MySQL Database With Yii with an example.

PHP Yii Application Configuration main DB (config/main.php)

Yii Database Connection – Sqlite Database

The PHP Based Frameworks The Yii Database To connect the Mysql sqlite db with web application, I should the folder Information of database.

'db'=>array(
    'connectionString' => 'sqlite:'.dirname(__FILE__).'/../pakainfo/livepaka.db',
),

Yii Database Connection – Mysql Database

The PHP Based Frameworks The Yii Database To connect the mysql db with web simple application, I should the Eneter your “localhost” hosting Information, database name(pakainfo), username(atmiya), and password(Jayu#$54#*&*#PakaInfo).

'db'=>array(
        'connectionString' => 'mysql:host=localhost;dbname=pakainfo',
        'emulatePrepare' => true,
        'username' => 'atmiya',
        'password' => 'Jayu#$54#*&*#PakaInfo',
        'charset' => 'utf8',
        ),

Excute Query

$clients = Yii::app()->db->createCommand()
        ->select('cname, cpass')
        ->from('user_mst')
        ->where('id=:id', array(':id'=>1))
        ->queryRow();

PHP Yii CDbConnection – Yii Database Connection

The Yii PHP based Frameworks CDbConnection display a connection to a simple database.

$connection=new CDbConnection($hosting,$username,$password);
$connection->active=true;

PHP Yii Excute Query

$sqlStatement="select cname, cpass from user_mst where id=:id limit 1";
$yii_conn=$connection->createCommand($sqlStatement);
$yii_conn->bindParam(':id',$cid);
$yii_conn->execute();  
$user=$yii_conn->query();

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Yii Database Connection.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

PHP Yii Framework Global Variables Tutorial with Examples 0

PHP Yii Framework Global Variables Tutorial with Examples

Today, We want to share with you PHP Yii Framework Global Variables Tutorial with Examples.
In this post we will show you Yii CApplication, hear for php – declaring global variables in yii and use them in controller we will give you demo and example for implement.
In this post, we will learn about CApplication global variables – Yii Framework with an example.

Yii CApplication ->Yii::app()

CApplication is the base class for all application classes. It contains global variables, functions etc. Below We put some IMP PHP based yii most reused methods or functions and some basic config properties of yii web application. Basically we will call simple this functions Like as “Yii::app()”

Properties/ Functions Output
echo Yii::app()->baseUrl /yiiapi
Yii::app()->timeZone UTC
Yii::app()->setLanguage()
Yii::app()->setId()
Yii::app()->setHomeUrl()
Yii::app()->setBasePath()
Yii::app()->name My Web Application
Yii::app()->localeDataPath D:\wamp\www\yiiapi\yiiframework\framework\i18n\data
Yii::app()->language en_us
Yii::app()->id 3fe52c6c
Yii::app()->homeUrl /yiiapi/index.php
Yii::app()->getTimeZone() UTC
Yii::app()->getLanguage() en_us
Yii::app()->getId() 3fe52c6c
Yii::app()->getHomeUrl() /yiiapi/index.php
Yii::app()->getBaseUrl() yiiapi
Yii::app()->getBasePath() D:\wamp\www\yiiapi\protected
Yii::app()->createUrl(“/”) /yiiapi/index.php
Yii::app()->createAbsoluteUrl(“/”) http://127.0.0.1/yiiapi/index.php
Yii::app()->basePath D:\wamp\www\yiiapi\protected
Yii::app()->SetTimeZone() Asia/Calcutta

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Yii CApplication.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

How to Open URL in New Tab using Yii Framework 0

How to Open URL in New Tab using Yii Framework

Today, We want to share with you How to Open URL in New Tab using Yii Framework.
In this post we will show you opening a link in new tab – Yii Framework, hear for yii2 – How to open a new window in YII framework 2.0 we will give you demo and example for implement.In this post, we will learn about PHP Yii Framework PHP redirect to external Link in new tab? with an example.

My Paka Knowledgeable Ideas, Tips and Tricks, Useful Content, Jobs, Technology, Earn Money, gmail creation, skype, yahoo and more useful things.

In Yii Framework, Open new window when target=”_blank”

<Link to="/about" target="_blank">About Pakainfo.com</Link>

Yii Framework Overview with Features

There are the Following the List of Features For Yii Framework Pure JavaScript Latest Frameworks.

Yii Framework redirect to a new tab

<?php echo TbHtml::stackedTabs(array(
    array('label' => 'E-mail BTPN', 'url' => 'https://pakainfo.com'),
)); ?>

PHP Yii Framework redirect to a new tab Example

<a href="https://pakainfo.com/" target="_blank">Click here</a>

Therefor in PHP Based Yii2 framework with Html simple helper in display data file We can simple source code Like as:

<?= Html::a("Pakainfo","https://pakainfo.com/",['target'=>'_blank']) ?>

And then in PHP framework yii2 Table grid We can display raw column:

[
  'attribute'=>'name',
  'format'=>'raw',
  'value'=>function ($model, $index, $widget){
     return Html::a(
           $model->name,                     
           ['module/api/update','id'=>$model->id], 
           [                                 
             'title'=>'Welcome to Pakainfo',
             'target'=>'_blank'
           ]
     );
  }
],

Yii Framework Redirects

//first way PHP YII Framework Redirecting
$this->redirect(array('https://pakainfo.com/'));

//second way PHP Framework Yii redirect with Param
$this->redirect(array('site/author','id'=>$model->id, 'title'=>$model->title));

//Like as 

Yii::app()-request->redirect('https://pakainfo.com/');

Yii Framework Redirecting To External Domains

//Redirect Script in Yii ->Yii redirect to referrer URL

$this->redirect(Yii::app()->request->urlReferrer);

There are main 3 type of the PHP Based framework Yii Redirect Option Like as

  • Redirect Anywhere
  • Redirect Within Controller
  • Redirect Between Controller

Redirect Between Controller

//PHP yii Framework Redirect between controller
$this->redirect(array("site_name/login"));
$this->redirect(array("error/display",array("error"=>$error));

Redirect Within Controller

//PHP yii Framework Redirect within controller
$this->redirect(array("users"));
$this->redirect(array("users",array("id"=>$id));

jQuery 15 Powerful Tips and Tricks for Developers and Web Designer

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Yii redirect to referrer URL.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Yii Framework Introduction and Hello World Tutorial 0

Yii Framework Introduction and Hello World Tutorial

Today, We want to share with you Yii Framework Introduction and Hello World Tutorial.
In this post we will show you Yii Framework Introduction and hello world example, hear for Yii First Hello World Tutorial we will give you demo and example for implement.
In this post, we will learn about Simple Yii Hello World Example Application with an example.

Basic Steps for some Yii framework

  • Prerequisities
  • Creating an Action
  • Creating a View
  • Trying it Out

Simple Prerequisities for Yii Framework using PHP

-PHP and databases (DB)
-SQL query
-simple web using PHP, HTML, CSS and DB.
-important is OOP (Object oriented programming)
Like as
+ actionSay classes
+ overriding functions
+ using constructor
+ public and private methods
+ Some propertie

Download the Yii Framework

Download

The directory structure of the Yii project site | Yii PHP Framework

 
 /
    backend/
    common/
        components/
        config/
            params.php
            params-local.php *
        lib/
            Pear/
            yii/
            Zend/
        migrations/
        models/
            Comment.php
            Extension.php
            ...some files
    console/
        commands/
            SitemapCommand.php
            ...some files
        config/
            main.php
            main-local.php *
            params.php
            params-local.php *
        runtime/
        yiic.php *
    frontend/
        components/
        config/
            main.php
            main-local.php *
            params.php
            params-local.php *
        controllers/
            SiteController.php
            ...some files
        lib/
        models/ 
            ContactForm.php
            SearchForm.php      
        runtime/
        views/
            layouts/
            site/
        www/
            assets/
            css/
            js/
            index.php *
    yiic
    yiic.bat
 

Yii framework : Creating an Action

controllers/SiteController.php

<?php
namespace app\controllers;
use yii\web\Controller;
class SiteController extends Controller
{
    // ...here is existing code some...

    public function actionSay($message = 'Hello - world in pakainfo.com')
    {
        return $this->render('say', ['message' => $message]);
    }
}

Simple Creating a View

<?php
use yii\helpers\Html;
?>
<?= Html::encode($message) ?>

Simple Trying it Out

http://yourhostname/index.php?r=site%2Fsay&message=Hello+World

Some Important Points for Yii framework

The Controllers should −

  • In controller,Be very thin.
  • In controller,Each action should contain only most a few lines of code useful.
  • In controller,Use Views for all responses data.
  • In controller,Not embed HTML.
  • In controller,Access the request data.
  • In controller,Call methods of used of models.
  • In controller,Not process the request some data.
  • In controller,These should be every processed in the model.

We hope you get an idea about Yii Hello World Application
We would like to have feedback on my Information blog .
Your valuable any feedback, Good question, Inspirational Quotes, or Motivational comments about this article are always welcome.
If you liked this post, Please don’t forget to share this as Well as Like FaceBook Page for Yii First Example Program.

We hope This Post can help you…….Good Luck!.

Top 10 Yii Interview Questions and Answers for fresher 0

Top 10 Yii Interview Questions and Answers for fresher

Today, We want to share with you Top 10 Yii Interview Questions and Answers for fresher.
In this post we will show you YII interview questions and answers for fresher, hear for Yii Interview Questions and Answers we will give you demo and example for implement.
In this post, we will learn about Top 10 YII Interview Questions & Answers with an example.

What is Yii?

Yii framework is a one type of the PHP framework which is based on pure MVC basic structure(Model View Controller).

What is current stable version of Yii?

Latest Version of yii framework in php is : 2.0.7 dated February 14, 2016.

Application Life Cycle of Yii framework ?

  • phase 1 : Pre-initialize the application with CApplication::preinit();
  • phase 2 : Set up the simple class autoloader and error handling;
  • phase 3 : Register core seimpl web-application components;
  • phase 4 : Load application easy setup configuration;
  • phase 5 : Initialize the web-application with CApplication::init() base
  • • Register web-application behaviors;
    • Load static new application components;

  • phase 6 : Raise an onBeginRequest event;
  • phase 7 : Process the user request:
  • • Collect information about the request;
    • new Create a new controller;
    • Run the simple controller;

  • phase 8 : Raise an onEndRequest generate event;

How to get current controller id in Yii ?

$controllerid = Yii::app()->controller->id;

How to get current action id in Yii ?

$actionid = Yii::app()->controller->action->id;

What are the type of models available in Yii framework ?

Form models and
active records.

List out some database related functions in Yii?

  • Query
  • find
  • findAll
  • findByPk
  • find By

What is the first file that gets loaded when you run a application using Yii framework?

index.php

How can we use ajax in Yii?

By the calling ajax helper model routing and then using it in controller to data routing for rendering.

what is directory structure for Yii framework?

 
 /
    backend/
    common/
        components/
        config/
            params.php
            params-local.php *
        lib/
            Pear/
            yii/
            Zend/
        migrations/
        models/
            Comment.php
            Extension.php
            ...some files
    console/
        commands/
            SitemapCommand.php
            ...some files
        config/
            main.php
            main-local.php *
            params.php
            params-local.php *
        runtime/
        yiic.php *
    frontend/
        components/
        config/
            main.php
            main-local.php *
            params.php
            params-local.php *
        controllers/
            SiteController.php
            ...some files
        lib/
        models/ 
            ContactForm.php
            SearchForm.php      
        runtime/
        views/
            layouts/
            site/
        www/
            assets/
            css/
            js/
            index.php *
    yiic
    yiic.bat
 

View More