Package installation error in Yii2 framework? - yii2

I have a requirement to use PHPOffice/PhpSpreadsheet, to install PhpSpreadsheet I followed this link.
So I installed PhpSpreadsheet into my project using 'composer' by running the command
composer require phpoffice/phpspreadsheet
at command prompt while installing it said that
Using version dev-master for phpoffice/phpspreadsheet
and was installed successfully(FYI check Screenshot), after installing when I tried to login into my application, I am getting a different error as
Cannot redeclare PHPMailerAutoload()
(previously declared in" for emails I am using 'phpmailer' including the path as
require_once('../vendor/phpmailer/PHPMailerAutoload.php');
as my "PHPMailer" folder resides in 'vendor' folder of Yii2 framework.
By the way I am building my application on Yii2 framework and I am very new to Yii2 framework.
Can anyone please tell, how to fix this? Thanks.

You don't have to use require for packages installed via composer. Yii autoload's feature will take care for that. You just have to write the appropriate use statements in your code. Actually, the mailer is a component declared into the main app, so you don't need the use statement at all
Yii::$app->mailer->compose('/my/mail_view', ['model' => $model])
->setFrom([Yii::$app->params['myMail'] => 'My Name'])
->setTo($model->email)
->setSubject('My subject')
->send();

Related

How to use MySQL for .NET Core Azure functions

I am attempting to write an Azure function and use MySQL but I cannot seem to use the MySQL.Data or MySql.Data.MySqlClient directives. The error I am getting is the following:
The type or namespace name 'MySql' could not be found.
I am not sure what I need to make this work
using MySql.Data;
using MySql.Data.MySqlClient;
This seems to be either Nuget/Project type issue. Try the following,
use NuGet to download the latest version. Just right click on the project and click 'Manage NuGet Packages' then search online for MySql.Data and install.
Check the project or create a new project
To change your project's framework right-click on your project select Properties -> Application -> Target framework.

CakePhp 3 elastic search

I have installed the elastic search based on the documentation
http://book.cakephp.org/3.0/en/elasticsearch.html
I am getting an error "Unknown repository type "Elastic". Make sure you register a type before trying to use it."
by adding $this->loadModel('test', 'Elastic');
Please make sure you have the Elasticsearch plugin installed via Composer.
And then load the plugin by adding a line in config/bootstrap.php.
Plugin::load('Cake/ElasticSearch', ['bootstrap' => true]);
*If you have Composer installed globally, run:
composer require cakephp/elastic-search "#stable"
in your application root directory. Hope this will help!

How to correct install and use plugin installed via composer

I installed a cakephp 3 app via composer from the root of my website c:wamp/www/my_app, and I developed untill i need to implement acl.
I installed the acl plugin for cakephp 3 via composer for the same path c:/wamp/www/myapp and i configured it, was everything well, but when i test the implementation of acl, i get the following error:
Missing Component, Create the class AclComponent below in file: src\Controller\Component\AclComponent.php
and seems to be true, theres no such file in the above location, instead the file is in vendor/cakephp/acl/src/controller/component.
Was investigating and i find that composer doesnt install plugins in a cake default path, theres many articles about, but how doi correct my installation? I already did all the stuff to implement the access control lists.
Thanks in advance error screenshot

Install curl and json extension in laravel

I am creating a registration form, i want to add a google captcha to the form however i noticed that the package requires PHP 5.4 or greater and "ext-curl" and "ext-json" i have looked around to try and find out how to get these dependencies installed but i have found no solution, currently when i try adding the google captcha package to my composer.json and doing a composer.update i get an error then i have to take it out from my composer.jon file and re-run composer update to fix the error. I think it might have something to do with these 2 dependencies does anyone know how i can get them installed?
I use the inbuilt PHP server in Laravel on windows 7 platform.
Directly from easyphp administration, use test code:
<?php phpinfo();?>

The type or namespace name 'Http' does not exist in the namespace 'System.Net' in WP8 app

I have this error in downloaded Windows Phone 8 app.
It is declared as
using System.Net.Http;
Seems like it must to work. How to make this work?
It is valid actually you have to install the Nuget package of System.Net.Http.
You can try Enable Nuget Package Restore in the solution. You can
do that by Right Click On Solution => Select Enable Nuget package
restore.
You can also achieve that by go Manage Nuget Packages e.g Project=>
Manage Nuget Packages => Search Online System.Net.Http => Install
the package.
Update Nuget Package :-
Tools=> Extensions and Updates => Updates. then update your Nuget.
Done :)