Quantcast
Channel: Live News for Yii Framework
Viewing all 3361 articles
Browse latest View live

[extension] bitcko/yii2-bitcko-paypal-api

$
0
0

Yii2 Bitcko PayPal PayPal Api Extension

  1. Installation
  2. Usage

Yii2 Bitcko PayPal Api extension use to integrate simple PayPal payment in your website.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require bitcko/yii2-bitcko-paypal-api:dev-master

or add

"bitcko/bitcko/yii2-bitcko-paypal-api": "dev-master"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by :

  1. Create developer account in PayPal and then create an app. PayPal Developer Dashboard.
  2. Copy and paste the client Id and client secret in params.php file that exists in app config directory:
    <?php
    

return [

'adminEmail' => 'admin@example.com',
'payPalClientId'=>'app client id here',
'payPalClientSecret'=>'app client secret here'

];

3. Configure the extension  in components section in web.php file exists in app config directory: 

```php
<?php
'components'=> [
    ...
 'PayPalRestApi'=>[
            'class'=>'bitcko\paypalrestapi\PayPalRestApi',
            'redirectUrl'=>'/site/make-payment', // Redirect Url after payment
            ]
            ...
        ]

  1. Controller example:
    call first the checkout action that will redirect you to the redirectUrl you mentioned in the previous step,
    in this example ("/site/make-payment")
    
<?php

namespace app\controllers;

use Yii;

use yii\web\Controller;

class SiteController extends Controller
{
   
    public function actionCheckout(){
        // Setup order information array with all items
        $params = [
            'method'=>'paypal',
            'intent'=>'sale',
            'order'=>[
                'description'=>'Payment description',
                'subtotal'=>44,
                'shippingCost'=>0,
                'total'=>44,
                'currency'=>'USD',
                'items'=>[
                    [
                        'name'=>'Item one',
                        'price'=>10,
                        'quantity'=>1,
                        'currency'=>'USD'
                    ],
                    [
                        'name'=>'Item two',
                        'price'=>12,
                        'quantity'=>2,
                        'currency'=>'USD'
                    ],
                    [
                        'name'=>'Item three',
                        'price'=>1,
                        'quantity'=>10,
                        'currency'=>'USD'
                    ],

                ]

            ]
        ];
        
        // In this action you will redirect to the PayPpal website to login with you buyer account and complete the payment
        Yii::$app->PayPalRestApi->checkOut($params);
    }

    public function actionMakePayment(){
         // Setup order information array 
        $params = [
            'order'=>[
                'description'=>'Payment description',
                'subtotal'=>44,
                'shippingCost'=>0,
                'total'=>44,
                'currency'=>'USD',
            ]
        ];
      // In case of payment success this will return the payment object that contains all information about the order
      // In case of failure it will return Null
      return  Yii::$app->PayPalRestApi->processPayment($params);

    }
}



[extension] yarcode/yii2-mailgun-mailer

$
0
0

Mailgun mailer component for Yii2 framework

  1. Installation
  2. Usage
  3. Licence
  4. Links

Build Status Latest Stable Version Total Downloads License

Mailgun is a transactional email cloud service. Say goodbye to your usual sendmail or postfix MTA problems. You can start sending emails via cloud without writing any line of code.

Installation

The preferred way to install this extension is through composer.

Either run

composer require --prefer-dist yarcode/yii2-mailgun-mailer

or add

"yarcode/yii2-mailgun-mailer": "*"

to the require section of your composer.json.

Usage

Configure YarCode\Yii2\Mailgun\Mailer as your mailer. ` 'mailer' => [

  'class' => \YarCode\Yii2\Mailgun\Mailer::class,
  'domain => 'example.org',
  'apiKey => 'CHANGE-ME',

], Now you can send your emails as usual. $message = \Yii::$app->mailer->compose() ->setSubject('test subject') ->setFrom('test@example.org') ->setHtmlBody('test body') ->setTo('user@example.org');

\Yii::$app->mailer->send($message); `

Licence

MIT

Links

[news] Yii 1.1.20 is released

$
0
0

We are very pleased to announce that Yii Framework version 1.1.20 is released. You can download it at yiiframework.com/download/.

This release is a release of Yii 1.1 that has reached maintenance mode and will, only receive necessary security fixes and fixes to adjust the code for compatibility with PHP 7 if they do not cause breaking changes. This allows you to keep your servers PHP version up to date in the environments where old Yii 1.1 applications are hosted and stay within the version ranges supported by the PHP team. Yii 1.1.20 is compatible with PHP 7.2 that, at the time of this writing, has an announced security support until November 30, 2020.

We recommend to use Yii 2.0 for new projects as well as introducing Yii 2.0 for developing new features in existing Yii 1.1 apps, as described in the Yii 2 guide. Upgrading a whole app to Yii 2.0 will, in most cases, result in a total rewrite so this option provides a way for upgrading step by step and allows you to keep old applications up to date even with low budget.

This release includes a few PHP 7 compatibility fixes and security improvements.

For the complete list of changes in this release, please see the change log. For upgrading, always make sure to read the upgrade instructions, however in this release there are no changes that require changes.

We would like to express our gratitude to all contributors who have spent their precious time helping improve Yii and made this release possible.

To comment on this news, you can do so in the related forum post.

[extension] bitcko/yii2-bitcko-mailer

$
0
0

Yii2 Bitcko PHPMailer

  1. Installation
  2. Usage

Bitcko Yii2 PHPMailer use to send emails from your project.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require bitcko/yii2-bitcko-mailer:dev-master

or add

"bitcko/yii2-bitcko-mailer": "dev-master"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by :

  1. Mailer configuration in config/web.php for basic temp or config/main.php for advanced.
<?php
'components'=> [
    ...
'BitckoMailer'=>[
            'class'=>'bitcko\mailer\BitckoMailer',
            'SMTPDebug'=> 2, // 0 to disable, optional
            'isSMTP'=>true, // default true
            'Host'=>'smtp.gmail.com', //optional
            'SMTPAuth'=>true, //optional
            'Username'=>'you google account username', //optional
            'Password'=>'your google account password', //optional
            'SMTPSecure'=>'tls', //optional, tls or ssl
            'Port'=>587, //optional, smtp server port
            'isHTML'=>true, // default true
        ],
            ...
        ]

  1. Controller example:
<?php

namespace app\controllers;

use Yii;

use yii\web\Controller;

class SiteController extends Controller
{
   
  public function actionSend()
     {
 
 
         $params = [
             'from'=>['address'=>'email address','name'=>'name here'],
             'addresses'=>[
                 ['address'=>'email address','name'=>'name here']
             ],
             'body'=>'email body here',
             
              //optional              
              'subject'=>'email subject here',
               //optional
              'altBody'=>'email alt body here',
               //optional
              'addReplyTo'=>[
                  ['address'=>'email address','information'=>'info here']
              ],
               //optional
              'cc'=>[
                  'email address'
              ],
               //optional
              'bcc'=>[
                  'email address'
              ],
              //optional
              'attachments'=>[
                 // ['path'=>'','name'=>'']
              ],
         ];
         
         return Yii::$app->BitckoMailer->mail($params); // return true if mail sent successfully
 
     }
}


[extension] miolae/yii2-markdown-doc

$
0
0

yii2-markdown-doc

  1. Installation
  2. Configure
  3. Usage

Yii2 module to display the content of all markdown file in a directory and its sub-folder.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist "miolae/yii2-markdown-doc" "2"

or add

"miolae/yii2-markdown-doc": "2"

to the require section of your composer.json file.

Configure

Configure config/web.php as follows

'modules' => [
    ................
    'doc'  => [
        'class' => 'miolae\yii2\doc\Module',
        // Directory to list
        'rootDocDir' => '@app/docs',
        // set false if you don't want to cache generated html, usefull for debugging 
        'cache' => true,
    ]
    ................
],

Usage

To access the doc, go to http://yoursite.com/doc/

[extension] mortezakarimi/yii2-gentelella-rtl

$
0
0
Gentelella RTL / قالب راست چین شده مدیریت برای فریمورک Yii2 ====================================================== قالب راست چین مدیریت مخصوص فریمورک Yii2 بر اساس قالب [gentelella-rtl](https://github.com/mortezakarimi/gentelella-rtl). این قالب بر اساس کد موجود در [yii2-gentelella](https://github.com/yiister/yii2-gentelella) پیاده سازی گشته است و شامل بسته‌های کد لازم و تعدادی ویجت و همچنین دارای ساختار قالب مورد نیاز برای پروژه می‌باشد. برای اطلاعات بیشتر در مورد نحوه استفاده از امکانات پکیج به ریپوزیتوری اصلی در این آدرس [yii2-gentelella](https://github.com/yiister/yii2-gentelella) مراجعه فرمایید. روش نصب ------------ بهترین روش نصب با استفاده از [composer](http://getcomposer.org/download/). اجرای دستور زیر ``` php composer.phar require --prefer-dist mortezakarimi/yii2-gentelella-rtl "~1.0.0" ``` یا افزودن ``` "mortezakarimi/yii2-gentelella-rtl": "~1.0.0‍" ``` به بخش `require ` در فایل `composer.json`. در آینده انجام خواهد شد --------------- در آینده نزدیک مستندات اضافه خواهد شد.

[wiki] Get Free Support: +1 800-564-1194 Coinbase Singapore Phone Number

$
0
0

Hi,

coinbase providing free technical support for all realated to coinabse and gdax issues for live help and support dial our coinbase toll free number +1 800-564-1194

[wiki] How to Get 1 800 564 1194 Coinbase Toll Free, Coinbase Customer Support Number?

$
0
0

is this coinbase toll free live help and support number for usa customers.

there are some serach realted quarry for gettting coinbase toll free numbers.

go to google.com

type there : coinabse toll free coinabse toll free number coinbase helpline number coinbase customer service number coinase customer support number coinbase support coinase contact toll free number

thanks for reading my artice for getting online help with coinbase.


[wiki] +1$$866-408-0361 Norton Customer Service Norton Customer Service Norton Customer Service Phone Number

$
0
0

==>>+ +1-866-408-0361++ Norton Customer Service Norton Support_USA

==>>+ +1-866-408-0361++ Norton Customer Service Norton Support_USA ==>>+ +1-866-408-0361++ Norton Customer Service Norton Support_USA ==>>+ +1-866-408-0361++ Norton Customer Service Norton Support_USA

==>>+ +1-866-408-0361++ Norton Customer Service Norton Support_USA ==>>+ +1-866-408-0361++ Norton Customer Service Norton Support_USA

==>>+ +1-866-408-0361++ Norton Customer Service Norton Support_USA

==>>+ +1-866-408-0361++ Norton Customer Service Norton Support_USA

==>>+ +1-866-408-0361++ Norton Customer Service Norton Support_USA ==>>+ +1-866-408-0361++ Norton Customer Service Norton Support_USA

==>>+ +1-866-408-0361++ Norton Customer Service Norton Support_USA

==>>+ +1-866-408-0361++ Norton Customer Service Norton Support_USA ==>>+ +1-866-408-0361++ Norton Customer Service Norton Support_USA

==>>+ +1-866-408-0361++ Norton Customer Service Norton Support_USA

==>>+ +1-866-408-0361++ Norton Customer Service Norton Support_USA

==>>+ +1-866-408-0361++ Norton Customer Service Norton Support_USA ==>>+ +1-866-408-0361++ Norton Customer Service Norton Support_USA ==>>+ +1-866-408-0361++ Norton Customer Service Norton Support_USA ==>>+ +1-866-408-0361++ Norton Customer Service Norton Support_USA ==>>+ +1-866-408-0361++ Norton Customer Service Norton Support_USA ==>>+ +1-866-408-0361++ Norton Customer Service Norton Support_USA ==>>+ +1-866-408-0361++ Norton Customer Service Norton Support_USA

==>>+ +1-866-408-0361++ Norton Customer Service Norton Support_USA

Contact Norton Tech Support Norton Customer Support Phone Number Norton Phone Number Tech Support Contact Norton Support Contact Norton Customer Support Norton Antivirus Helpline Number Norton Customer Support Number Norton Helpline Number Norton Com Tech Support Norton 360 customer support live chat Norton 360 customer support number :idea: :evil: :D :) :lol: :( :o :shock: Norton 360 customer support phone Norton 360 customer support phone number us Norton 360 customer support support Norton 360 customer support usa phone number Norton 360 for phone Norton 360 free 360 support Norton 360 help desk support phone number free in usa Norton 360 help phone number Norton 360 helpline number Norton 360 online support Norton 360 phone Norton 360 phone number Norton 360 phone number customer support Norton 360 phone number in usa Norton 360 phone number support for technical issue in usa Norton 360 phone number usa Norton 360 phone support number Norton 360 plus tech support Norton 360 protection Norton 360 support Norton 360 support center Norton 360 support number Norton 360 support supports Norton 360 support telephone number Norton Customer Service Phone Number Norton Antivirus Tech Support Phone Number Norton Antivirus Phone Number Norton Support Phone Number Norton Customer Service Number Norton Customer Support Norton Tech Support Phone Number Norton Support Number Norton Total Support Norton Antivirus Tech Support Number Norton Antivirus Support Phone Number Norton Antivirus Customer Service Phone Number Norton Tech Support Number Norton Antivirus Contact Number Norton Antivirus Support Norton Contact Support Norton Helpline Phone Number Norton Antivirus Support Number Phone Number For Norton Customer Service Norton Phone Support Norton Number Contact Norton Tech Support Norton Customer Support Phone Number Norton Phone Number Tech Support Contact Norton Support Contact Norton Customer Support Norton Antivirus Helpline Number Norton Customer Support Number Norton Helpline Number Norton Com Tech Support Norton Help Phone Number Norton Support Contact Norton Antivirus Customer Support Number Norton Help Number Norton Customer Support Phone Norton Customer Number Norton Contact Info Norton Support Phone Number Usa Norton Customer Service Phone Number Usa Norton Customer Service Phone Number Us Norton Tech Support Number Usa Norton Support Phone Number Us Norton Support Hotline Norton Contact Number Norton Customer Care Norton Customer Care Number Norton Customer Care Phone Number Norton Customer Care Toll Free Number Norton Customer Service Telephone Number Norton Antivirus Customer Care Norton Antivirus Customer Care Number Norton Antivirus Customer Service Norton Antivirus Customer Service Number Norton Antivirus Customer Support Norton Antivirus Customer Support Phone Number Norton Antivirus Tech Support Norton Antivirus Technical Support Norton Antivirus Technical Support Number Norton Antivirus Technical Support Phone Number Norton Antivirus Toll Free Number Norton tech support number Norton customer support telephone number Norton antivirus customer support number Norton internet security technical support Norton antivirus customer support phone number Norton antivirus customer support phone number Norton antivirus customer support number Norton antivirus customer support number phone number for Norton antivirus customer support Norton antivirus customer support Norton antivirus customer support phone number us Norton antivirus phone number customer support us phone number Norton antivirus customer support Norton antivirus phone number customer support customer support number for Norton antivirus Norton antivirus customer support phone Norton tech support phone number us Norton tech support number Norton customer support phone number Norton customer support phone number Norton phone number customer support Norton security phone number customer support phone number for Norton customer support Norton customer support phone number Norton internet security customer support phone number Norton Antivirus tech support phone number aus free Norton Antivirus technical support phone number aus Norton Antivirus technologies phone number aus Norton Antivirus telephone support number aus Norton Antivirus support telephone number aus aus Norton telephoNe Number Norton antivirus toll free Number usa Norton support services Number techNical support for Number Canon Norton support phone number usa Norton Number customer care Number usa Norton antivirus customer care Number Norton customer care ceNter Norton customer support Norton customer support phoNe Norton customer helphNorton Norton support phone number Norton antivirus support phoNe Number Norton tech support phoNe Number Norton customer support phoNe Number Norton tech support phoNe Number Norton helpliNe Number Norton helpdesk phoNe Number Norton toll free Number Norton coNtact Number Norton telephoNe Number. Norton support phone number Norton support phoNe Number Norton techNcal support phoNe Number. Norton techNical support Number Norton tech support Number Norton customer support Number Norton support phone number Norton helpliNe Number Norton coNtact Number Norton telephoNe Number Norton customer & techNical support Norton customer portal Norton customer care phoNe Number usa Norton 360 customer support phone Norton tech support phone number us Norton tech support number Norton customer support phone number Norton customer support phone number Norton phone number customer support Norton security phone number customer support phone number Norton customer support Norton customer support phone number Norton internet security customer support phone number Norton 360 Tech Support Customer Service 24/7 Norton 360 tech support phone number U.S. free Norton 360 technical support phone number U.S. Norton 360 technologies phone number U.S. Norton 360 telephone support number U.S. Norton 360 support telephone number U.S. U.S. Norton 360 customer service number U.S. Norton 360 plus tech support Norton 360 technical support phone number U.S. Norton 360 technical support number U.S. Norton 360 technical support help desk phone number U.S. Norton 360 technical support number U.S. toll free number U.S. Norton 360 technical support phone number U.S. Norton 360 customer support phone number U.S. Norton 360 customer service phone number U.S. Norton 360 customer support phone number U.S. Norton 360 customer service phone number U.S. phone number U.S. Norton 360 customer service contact Norton 360 customer service phone number U.S. Norton 360 customer service phone number U.S. phone number U.S. Norton 360 customer service Norton 360 security support phone number U.S. Norton 360 tech support phone number Norton 360 support phone number Norton 360 customer support phone number Norton 360 technical support phone number Norton 360 technical support phone number phone number Norton 360 technical support Norton 360 customer service phone number Norton 360 customer service number Norton 360 technical support number Norton 360 customer support number Norton 360 tech support number phone number Norton 360 support Norton 360 support phone number Norton 360 phone number customer service Norton customer support phone numbers Norton security customer support phone number Norton phone number customer support phone number Norton customer support Norton support phone number Norton telephone support number Norton 360 customer support telephone number Norton 360 toll free customer care number Norton technical support number Norton support phone number Norton technical support phone number Norton technical support phone number Norton customer support phone number Norton customer support phone number Norton 360 customer care number usa Norton 360 customer support email address Norton 360 customer support in usa Norton 360 customer support live chat Norton 360 customer support number :idea: :evil: :D :) :lol: :( :o :shock: Norton 360 customer support phone Norton 360 customer support phone number us Norton 360 customer support support Norton 360 customer support usa phone number Norton 360 for phone Norton 360 free 360 support Norton 360 help desk support phone number free in usa Norton 360 help phone number Norton 360 helpline number Norton 360 online support Norton 360 phone Norton 360 phone number Norton 360 phone number customer support Norton 360 phone number in usa Norton 360 phone number support for technical issue in usa Norton 360 phone number usa Norton 360 phone support number Norton 360 plus tech support Norton 360 protection Norton 360 support Norton 360 support center Norton 360 support number Norton 360 support supports Norton 360 support telephone number Norton 360 tech support Norton 360 technical support help desk phone number Norton 360 technical support number Norton 360 toll free customer care number Norton 360 toll free number Norton customer care number Norton customer care number usa Norton customer support number usa Norton customer support reviews Norton customer support support phone number Norton help desk phone number in usa Norton helpline phone number Norton internet security customer support Norton internet security help phone number Norton internet security phone number customer support Norton internet security support phone number ==>>+ +1$866-408-0361++ Norton Customer Service Norton Support_USA

==>>+ +1$866-408-0361++ Norton Customer Service Norton Support_USA ==>>+ +1-866-408-0361++ Norton Customer Service Norton Support_USA ==>>+ +1-866-408-0361++ Norton Customer Service Norton Support_USA ==>>+ +1-866-408-0361++ Norton Customer Service Norton Support_USA ==>>+ +1$866-408-0361++ Norton Customer Service Norton Support_USA ==>>+ +1$866-408-0361++ Norton Customer Service Norton Support_USA

[wiki] Yii2: How to create/develop a new extension using Composer locally without version control or Git

$
0
0

Using a version control system, like Git, is nice. However, when building an extension from scratch and loading it via Composer, it adds a lot of pain in the butt steps. You have to commit your changes, update composer to pull them over, then notice there is an error, fix, commit, update. repeat.. I don't want all my baby steps under Git. Sure, I could edit my commit history, but c'mon. Just let me code! I will put it under version control once I get a baseline created. This guide will show you how to setup your composer.json to load a local directory (everything inside, live). You make a change, save the file, refresh the page, boom.

What about after you have a release of your extension, but you want to work on it to add a new feature or fix a bug? It needs to be useable in Yii2 while you work on it. So again, we don't need all the extra steps. Using the instructions in this guide, you will be able to edit your composer.json to load the files live via a symbolic link. You won't have to commit or update to see your changes in your Yii app!

This is the best way to develop new extensions for Yii! It is also the best way to work on your already existing extensions to fix bugs or add new features!

First, lets create a directory for our new extension. I am on a Mac and use XAMPP, so your paths may vary. I don't want to put my extension inside my Yii2 app because it is separate, meant to be pushed to Git and Packagist, and shared with the world, and used later. It is independent, I am just using my Yii2 app as a testing ground to build it, even if I am planning on using it inside the app for real.

cd /Applications/XAMPP/xamppfiles/htdocs
mkdir yii2-myextension
cd yii2-myextension
composer init

Follow the interactive wizard. I use Atom, and I would open a new Atom editor window, then "File > Add Project Folder" and select "yii2-myextension" to open the whole directory to work in. Now, we will only have "composer.json" in here so far. Open it.

You will notice that "init" automatically created a basic composer file. Here is mine, excluding keywords, description, etc. because those don't really matter.

{
    "name": "wadeshuler/yii2-myextension",
    "type": "yii2-extension",
    "minimum-stability": "dev",
    "autoload": {
        "psr-4": {
            "wadeshuler\\myextension\\": ""
        }
    }
}

Name: The name is /yii2-. I use my GitHub username (WadeShuler), all lowercase and no spaces (wadeshuler). It would help if you create a GitHub account first, and also create a Packagist account. Packagist uses your GitHub username :) Keep those 3 in sync and you will reduce issues. You should also prefix your extensions with "yii2-". It is a Yii standard practice, helps others know it is for Yii2 and not Yii1.

Type: You must use "yii2-extension" for the type, this tells Yii to load it into your extensions file for internal use. Click here to read more.

Min Stability: it is important to use "dev" here during testing. We have no version control (yet) and we will force our main Yii2 composer.json to accept a "dev" dependency even though Yii2 requires stable, by using "@dev" for the repo (shown later).

Autoload: I use PSR-4 and you probably should too. Most Yii2 packages I have encountered are PRS4. I feel it is better an easier, I don't just follow suit to be a sheep :P Notice how it has my vendor name, "wadeshuler" then double backslashes. These are important. If you don't know about the double backslashes, then read here. It then has the name of my extension. However, there is no "yii2" in it. This is actually the namespace we are going to use, we can call it whatever we want, so we can omit the "yii2-" to be cleaner and easier to write later. This is the namespace that defines where your extension is located. Here in Composer, we are saying "wadeshuler/whateveriwant" is going to be our namespace, and it is located "" <-- root dir of the loaded extension. You could do "wadeshuler\myextension\": "/src" <-- in your extensions src directory if you want to put everything in a "src" dir and just have your "README", "LICENSE" and "composer.json" in your extensions root dir.

Ok, so here, your Yii2 extension is ready for use in Composer. We will add files later. Right now, there is nothing but "composer.json" in our directory.

We need to load our extension into our Yii2 app. Open your Yii2 app's "composer.json" file, lets add our extension.

    "require-dev": {
        "wadeshuler/yii2-myextension": "@dev"
    },
    "repositories": [
        {
            "type": "path",
            "url": "/Applications/XAMPP/xamppfiles/htdocs/yii2-myextension"
        }
    ],

You probably don't have a "repositories" section, so add it. Notice we use "path" for the type, this does not require any version control :) For the url, I use the full path to the extension I am currently working on. This will actually create a symbolic link to the directory, which is key for live editing! I added my extension to the "require-dev" section, because it is development. Just in case this was pushed to the server, I don't want to break anything. When it's all done and on Packagist, I would put it where it belongs and remove the entry in "repositories" so it loads from Packagist and not my local computer.

Now we are ready to run: ~~~ composer update ~~~

If everything is correct, you should see Composer load your library when watching your terminal output. Open your Yii2 app in your editor and view the "vendor" directory, look for your namespace dir (wadeshuler for me), then under it you should see a directory for your extension. Now, it is empty. If it loaded fine, you are ready to start building your extension. All changes are live in your main Yii app so you can test while coding! No committing, no updating. Just edit, save, refresh!!!

When you are done and your extension is perfect, you can then put it under version control, push it to GitHub and Packagist. Then you remove the "repositories" section so it no longer links to your local directory, and edit the "require-dev" just like adding anything else from Packagist. How to add your Packagist package is beyond the scope of this tutorial. However, the gist is, you must make a "release" in GitHub in order for Packagist to work.

Ok, so now your extension is great, however there is a bug you need to fix and you want to add a new feature.. Here is what I would do.

We don't need to commit or update for this either. Revert your "composer.json" back to how I showed above, so you are "live editing" again. If you lost your project, you could "git clone" it back into your "htdocs". You can combine live editing and with your GitHub workflow. You can create a branch, live edit your files, and commit when ready. This is possible because when you switch the branch, the files are actually swapped instantly. So the file has your code, even if you haven't committed it yet! We aren't relying on any VCS, just the files like the good ole days.

Once you fixed your repo and have committed the changes, push it back to GitHub.

[wiki] A universal model attribute for its synthetic representation

$
0
0
  1. Example
  2. General considerations

It is convenient to use the same identification attribute, say info, in all of the active records of your application. It should be a virtual read-only attribute defined by a getter method, its label being the model name.

One can easily use the info attribute in breadcrumbs, detail views, grid views and other places. It will be $model->info instead of $model->id, $model->name or $model->name . ' ' . $model->lastname.

Example

Let us consider a hypothetical application treating states and cities having one-to-many relation.

Models
class State extends ActiveRecord
{
    // ...

    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => 'State name',
            // ...
            'info' => 'State',
        ];
    }

    public function getInfo()
    {
        return $this->name;
    }
}

class City extends ActiveRecord
{
    // ...

    public function getInfo()
    {
        return $this->name;
    }

    public function getState()
    {
        return $this->hasOne(State::className(), ['id' => 'state_id']);
    }
}

The info attribute can be used throughout the application.

Title and breadcrumbs

This is the fragment of the city update view:

$this->title = 'Update ' . $model->info;
$this->params['breadcrumbs'][] = ['label' => 'States', 'url' => ['state/index']];
$this->params['breadcrumbs'][] = ['label' => $model->state->info, 'url' => ['state/view', 'id' => $model->state_id]];
$this->params['breadcrumbs'][] = ['label' => $model->info, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Update';

The page title "Update Seattle" is more informative then "Update City: 123" generated by the standard Gii template.

Cancel button

A cancel button in the state or the city view:

<?= Html::a(
    'Delete',
    ['delete', 'id' => $model->id],
    [
        'class' => 'btn btn-danger',
        'data' => [
            'confirm' => "Deleting {$model->info}. Are you sure?",
            'method' => 'post',
        ],
    ]
) ?>

This button, when pressed, asks: "Deleting Seattle. Are you sure?" instead of the standard "Are you sure you want to delete this item?".

DetailView attribute

A hyperlink in the detail view:

<?= DetailView::widget([
    'model' => $model,
    'attributes' => [
        // ...
        [
            'attribute' => 'state_id',
            'format' => 'raw',
            'value' => Html::a($model->state->info, ['state/view', 'id' => $model->state_id]),
        ],
    ],
]) ?>
GridView column

A column in a cities grid view:

<?= GridView::widget([
    'dataProvider' => $dataProvider,
    'columns' => [
        // ...
        'state.info',
    ],
]); ?>

In this case the 'state.info' column label will be 'State', according to the City model definition.

The dropDownList

In the drop down list of the city's form:

<?= $form->field($model, 'state_id')
    ->dropDownList(
        ArrayHelper::map(State::find()->all(), 'id', 'info'),
        ['prompt' => 'Select one']
    )
?>

General considerations

Universality

The universal info attribute simplifies the application design because the developer should not remember the attribute names for every model used. Also, the info attribute label is always the model name, so the 'father.grandfather.info' column specification in the detail or grid views do not require the implicit label specification, like 'father.grandfather.info:text:My label'.

The info attribute is similar to the __toString() method used to convert any PHP object to the string.

The info attribute does not guarantee the unambiguous identification string, but gives a rapid information on the model in question.

Custom ActiveRecord class

If most of your models have the name attribute or similar data useful for identification, it is helpful to define you own ActiveRecord class:

class ActiveRecord extends \yii\db\ActiveRecord
{
    // ...

    /**
     * @return string Instantiated model name
     */
    public function getCalledClassName()
    {
        $reflectionClass = new \ReflectionClass(get_called_class());
        return $reflectionClass->getShortName();
    }

    /**
     * @return string Short description of the model
     */
    public function getInfo()
    {
        // Take the model name
        $m = $this->getCalledClassName();

        // Compound info in different cases
        if ($this->isNewRecord)
            $i = 'New ' . $m;
        elseif ($this->hasAttribute ('name') and trim($this->name))
            $i = trim($this->name);
        // ... other cases specific to your application
        else
            $i = $m . ' ' . $this->id;

        // Return the result
        return $i;
    }
}
Override getInfo()

In some models you can override the default getInfo() method defined in your ActiveRecord class. For example, the active record of a person can be identified by the first and the last name:

class Person extends ActiveRecord
{
    // ...

    public function attributeLabels()
    {
        return [
            // ...
            'info' => 'Person',
        ];
    }

    public function getInfo()
    {
        // The first and the last names combined
        $i = trim(trim($this->name) . ' ' . trim($this->lastname)]);

        // If empty, take the default value
        if (! $i)
            $i = parent::getInfo();

        // Return the result
        return $i;
    }
}

The info value is never empty. Some possible examples of its values:

  1. Jane Doe
  2. Jane
  3. Doe
  4. Person 123
  5. New Person

The case 1 is when there are both the first and the last names evaluated. The cases 2 and 3 are when there is only the first or only the last name evaluated, respectively. The case 4 is when the first and the last names are both empty. The last case is for a new record not yet saved to the database.

Search ActiveRecord class

The info attribute should be defined as not searchable in the search class:

class PersonSearch extends Person
{
    // ...
    public function rules()
    {
        return [
            // ...
            [['!info'], 'safe', 'on' => '*']
        ];
    }
}
Gii templates

One can include the above code examples in the customized Gii model and CRUD templates.

[wiki] Installation guide: Yii-2 advanced template with RBAC system

$
0
0

Welcome, all of you !

Here I am giving the steps for an easy installation of yii2-advanced template with an RBAC(Role Based Access Control) system.

Installtion : Yii2 - advanced template

Here we are going to install yii2-advanced template using composer. So if you don't have composer in your machine, please download and install the latest version of it. After installing composer please check whether it is accessible from the CMD by running the command composer like:

C:\>composer

If the above command gives a +ve response, then it's okay. Now we can start.

Open a new CMD window and locate to your server root directory. I am using wamp server so myself would be like:

C:\>cd wamp\www
C:\wamp\www>

Then run the command composer create-project --prefer-dist yiisoft/yii2-app-advanced yii2-app for creating a new application named as yii2-app like:

C:\wamp\www>composer create-project --prefer-dist yiisoft/yii2-app-advanced yii2-app

The template will be downloaded from git repository. After the template is installed, locate to the newly created application directory C:\wamp\www\yii2-app in CMD like:

C:\wamp\www>cd yii2-app
C:\wamp\www\yii2-app>

Then you should initialize the application by running php init in CMD. The initialization will generate the entry scripts and config files for your application. Run the command like:

C:\wamp\www\yii2-app>php init

You can select the environment type from the given options:

Which environment do you want the application to be initialized in?

  [0] Development
  [1] Production

  Your choice [0-1, or "q" to quit]

Now the installation of yii2-advanced template is completed, but still there is no database. So we want to create and use a database too. First of all we should install an RBAC module. Here I am using yii2-admin for RBAC. Take a look at the following steps:

Installation: RBAC system into your application

From the CMD window run the command composer require mdmsoft/yii2-admin "~2.0" for installing yii2-admin into your newly created application like:

C:\wamp\www\yii2-app>composer require mdmsoft/yii2-admin "~2.0"

It will be downloaded from git. After installation, the package (yii2-admin) will be located in the yii2-app/vendor/mdmsoft directory.

Then you should add some parameters to the configuration file yii2-app/common/config/main.php to access the yii2-admin and authManager as:

'modules' => [
    'admin' => [
        'class' => 'mdm\admin\Module',
        ...
    ]
    ...
],
...
'components' => [
    ...
    'authManager' => [
        'class' => 'yii\rbac\PhpManager', // or use 'yii\rbac\DbManager'
    ]
],

Create a database in MySql and configure your yii2-app/common/config/main-local.php file by adding the database credentials. Currently, there is no user table in your database. So you need to create user table for user management. For this yii2 provides an option for database migration. Run the command yii migrate --migrationPath=@mdm/admin/migrations in CMD for creating a proper user table for the user management. In CMD,

C:\wamp\www\yii2-app>yii migrate --migrationPath=@mdm/admin/migrations

The above command will create user and menu tables for your application.

Then change the user component properties in config file yii2-app/common/config/main.php as:

'components' => [
    ...
    'user' => [
        'identityClass' => 'mdm\admin\models\User',
        'loginUrl' => ['admin/user/login'],
    ]
]

Populate the user table by adding users. Use this link to register users to your application:
http://localhost/yii2-app/backend/web/index.php?r=admin/user/signup

You can use authManager class 'yii\rbac\DbManager' to authorize users using database. For that you should execute a database migration using the command yii migrate --migrationPath=@yii/rbac/migrations. Before that add 'class' => 'mdm\admin\models\User' and change the authManager class in the config file yii2-app/common/config/main.php like :

'components' => [
    ...
    'authManager' => [
        'class' => 'yii\rbac\DbManager', // or use 'yii\rbac\PhpManager'
    ],
    'user' => [
        'class' => 'mdm\admin\models\User',
        'identityClass' => 'mdm\admin\models\User',
        'loginUrl' => ['admin/user/login'],
    ]
]

and remove 'class' => 'mdm\admin\models\User' from the config file after migration. Execute the migration as:

C:\wamp\www\yii2-app>yii migrate --migrationPath=@yii/rbac/migrations

Don't forget to remove 'class' => 'mdm\admin\models\User' from the config file yii2-app/common/config/main.php.

You can use the following RBAC URLs to create and manage permissions/roles to the users:

http://localhost/yii2-app/backend/web/index.php?r=admin
http://localhost/yii2-app/backend/web/index.php?r=admin/route
http://localhost/yii2-app/backend/web/index.php?r=admin/permission
http://localhost/yii2-app/backend/web/index.php?r=admin/menu
http://localhost/yii2-app/backend/web/index.php?r=admin/role
http://localhost/yii2-app/backend/web/index.php?r=admin/assignment
http://localhost/yii2-app/backend/web/index.php?r=admin/user

Then you can create and manage routes/permissions/roles and assign them to the existing users using this interface. After setting the routes/permissions/roles, for checking whether a user has access to a particular action in a controller you need to add access control configuration parameters to the yii2-app/common/config/main.php file.

return [
    'modules' => [
        ....
    ],
    ....
    'as access' => [
        'class' => 'mdm\admin\components\AccessControl',
        'allowActions' => [
            'site/*',
            'admin/*',
        ]
    ]
]

You can add the public actions in allowActions array. The other actions will be checked by the AccessControl class for authorization.

Use the following github links for more instructions about yii2-advanced and yii2-admin:
https://github.com/yiisoft/yii2-app-advanced
https://github.com/mdmsoft/yii2-admin

Hope this article will help you to install yii2 and RBAC easily. Thanks for reading.

Happy coding :)

[wiki] How to make bootstrap tabs remain active/selected after navigating to different web pages.

$
0
0

Bootstrap tabs gets unselected/inactive when user navigates to other page and comes back. How to make bootstrap tabs remain active/selected after navigating to different web pages.

Steps :> 1: Add class dashboard_tabs_cl to <ul>.

<!-- Nav tabs -->
<ul class="nav nav-tabs dashboard_tabs_cl" role="tablist">

2: Add javascript to the page.

<?php $this->registerJs(
'$("document").ready(function(){
	if (typeof(Storage) !== "undefined") {
				
		var dash_localVar = localStorage.getItem("dash_activ_tab"+getUrlPath());
		if(dash_localVar){

			$(".dashboard_tabs_cl > li").removeClass("active");
			$(".tab-content > div").removeClass("active");

			var hrefAttr = "a[href=\'"+dash_localVar+"\']";
			if( $(hrefAttr).parent() ){
				$(hrefAttr).parent().addClass("active");
				$(""+dash_localVar+"").addClass("active");
			}
				
		}

		$(".dashboard_tabs_cl a").click(function (e) {
			//alert(window.location.pathname);					
			e.preventDefault();
			localStorage.setItem("dash_activ_tab"+getUrlPath(), $( this ).attr( "href" ));
		});
		function getUrlPath(){
			var returnVar = "_indexpg";
			var splitStr = window.location.href;
			var asdf = splitStr.split("?r=");
			if(asdf[1]){
				var furthrSplt = asdf[1].split("&");
				if(furthrSplt[0]){
					returnVar = furthrSplt[0];
				}else{
					returnVar = asdf[1];
				}
			}
			return returnVar;
		}
	}
	});'
); ?>

Done!.

[extension] slavkovrn/yii2-googlechart

$
0
0

Google Chart for Yii2 Framework

The extension uses Google library https://www.gstatic.com/charts/loader.js and makes chart from php array of structure defined.

Google Chart

Installation

Install with composer:

composer require slavkovrn/yii2-googlechart

or add

"slavkovrn/yii2-googlechart": "*"

to the require section of your composer.json file.

Set link to extension in your view:

use slavkovrn\googlechart\GoogleChartWidget;

$data = [
    'SIN' => [
                number_format(0,5) => sin(0),
                number_format(Pi()/4,5) => sin(Pi()/4),
                number_format(Pi()/2,5) => sin(Pi()/2),
                number_format(Pi()/2+Pi()/4,5) => sin(Pi()/2+Pi()/4),
                number_format(Pi(),5) => sin(Pi()),
                number_format(Pi()+Pi()/4,5) => sin(Pi()+Pi()/4),
                number_format(Pi()+Pi()/2,5) => sin(Pi()+Pi()/2),
                number_format(Pi()+Pi()/2+Pi()/4,5) => sin(Pi()+Pi()/2+Pi()/4),
                number_format(2*Pi(),5) => sin(2*Pi()),
             ],
    'COS' => [
                number_format(0,5) => cos(0),
                number_format(Pi()/4,5) => cos(Pi()/4),
                number_format(Pi()/2,5) => cos(Pi()/2),
                number_format(Pi()/2+Pi()/4,5) => cos(Pi()/2+Pi()/4),
                number_format(Pi(),5) => cos(Pi()),
                number_format(Pi()+Pi()/4,5) => cos(Pi()+Pi()/4),
                number_format(Pi()+Pi()/2,5) => cos(Pi()+Pi()/2),
                number_format(Pi()+Pi()/2+Pi()/4,5) => cos(Pi()+Pi()/2+Pi()/4),
                number_format(2*Pi(),5) => cos(2*Pi()),
             ],
];

echo GoogleChartWidget::widget([
    'id' =>'google-chart',
    'title' => 'Google Chart',
    'style' => 'width:100%',
    'data' => $data,
]);

[extension] maslosoft/mangan


[extension] maslosoft/signals

[extension] maslosoft/hedron

[extension] maslosoft/manganel

[extension] maslosoft/embedi

[wiki] Pjax GridView: refresh page after delete

$
0
0

Normally, after clicking the delete button in gridview, the record will be deleted and the page will refresh, but the page number in query string is lost. This is not always the case we expect.

How to refresh current page with pjax after deleting the record? It seems there is no very simple solution.

  1. Controller file

     public function actionDelete($id)
     {
         $this->findModel($id)->delete();
         if (Yii::$app->request->isAjax) {
             Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
             return ['success' => true];
         }
         return $this->redirect(['index']);
     }
    
  2. index.php (view file)

    <?php
     $this->registerJs("
         $(document).on('ready pjax:success', function() {
             $('.pjax-delete-link').on('click', function(e) {
                 e.preventDefault();
                 var deleteUrl = $(this).attr('delete-url');
                 var pjaxContainer = $(this).attr('pjax-container');
                 var result = confirm('Delete this item, are you sure?');                                
                 if(result) {
                     $.ajax({
                         url: deleteUrl,
                         type: 'post',
                         error: function(xhr, status, error) {
                             alert('There was an error with your request.' + xhr.responseText);
                         }
                     }).done(function(data) {
                         $.pjax.reload('#' + $.trim(pjaxContainer), {timeout: 3000});
                     });
                 }
             });
    
         });
     ");
    ?>
    
    <?php Pjax::begin(['id' => 'my_pjax']); ?>
     <div class="shop-index">
         <?= GridView::widget([
             'dataProvider' => $dataProvider,
             'filterModel' => $searchModel,
             'columns' => [
                 'id',
                 [
                     'class' => 'yii\grid\ActionColumn',
                     'buttons' => [
                         'update' => function ($url, $model) {
                             return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [
                                 'class' => 'pjax-update-link',
                                 'title' => Yii::t('yii', 'Update'),
                             ]);
                         },
                         'delete' => function ($url, $model) {
                             return Html::a('<span class="glyphicon glyphicon-trash"></span>', false, [
                                 'class' => 'pjax-delete-link',
                                 'delete-url' => $url,
                                 'pjax-container' => 'my_pjax',
                                 'title' => Yii::t('yii', 'Delete')
                             ]);
                         }
                     ],
                 ],
             ],
         ]); ?>
     </div>
    <?php Pjax::end(); ?>
    
Viewing all 3361 articles
Browse latest View live