simplemailer and yii framewoork - php

I started working on yii framework in last 2-3 days....
i am trying to follow this tutorial simple mailer ....
After copying the files into extension folder and after writing these lines into configuration file, when I openned the index page of my test application, it gives me the following exception:
throw new CException(Yii::t('yii','Object configuration must be an array containing a "class" element.'));
and below is the screenshot of stacktrace:
Can anyone help me out here?

after copying the files into extension folder
You have to copy simplemailer into modules directory '/protected/modules/...
cp modules/SimpleMailer/commands/MailerCommand.php commands/
Execute installations:
http://www.yiiframework.com/extension/simplemailer#hh6
cd /your/app/directory/protected
./yiic migrate create add_simplemailer_tables
--templateFile=application.modules.SimpleMailer.migrations.template
./yiic migrate up
cp modules/SimpleMailer/commands/MailerCommand.php commands/

Related

Laravel 5.7, preset bootstrap error. Failed to open stream

I'm trying to use the laravel 5.7 bootstrap4 preset, but have problems using it.
Do you guys know why I see this error? Why is the file missing? I have not changed the path to anything.
kgp43:~/workspace (master) $ php artisan preset bootstrap
In Bootstrap.php line 41:
copy(/home/ubuntu/workspace/resources/sass/_variables.scss): failed to open stream: No such file or directory
I found the error.
All folders in the Assets directory has to be moved up one level.
It should not be needed to move the content of the Assets folder (accoring to laravel - but it was for me to run the preset command.
https://laravel.com/docs/5.7/upgrade

Using encore webpack with symfony project

I'm using the Encore/Webpack in my Symfony project, but Im having troubles with the installation.
I'm following the official guide: Link to official guide
My project folder:
projectname
---/app
---/assets
/css
/global.scss
/js
/main.js
...
---/node_modules
/.bin
/encore
...
---/web
/build
etc
I was following
Create a new file called webpack.config.js at the root of your
project.
It looks like:
projectname
...
webpack.config.js
I filled it with the example code. Afterwards I wanted to 'build' the assets with the command encore dev on path: projectname\node_modules\.bin
When I do this, I get the following error code:
Running webpack ...
No configuration file found and no output filename configured via CLI option.
A configuration file could be named 'webpack.config.js' in the current directory.
Use --help to display the CLI options.
I have no idea what I'm doing wrong. When I move the webpack.config.js to the .bin folder.. that part works, but than the build doesn't work, because it wants to install the files into .../.bin/build/ which is not correct. I want it into projectname/build like the example.
try this commend it's work for me
install webpack-notifier#^1.6.0 --save-dev

migration doesn't work in cloned projent in yii2

I have cloned the project from Github and tried to run the migration to make the database but it does not work. Why?
I get the following error:
bash: ./yii: No such file or directory
Path to yii file is incorrect. make sure current directory of command line is set to project root where 'yii' file is stored.

PHPUnit cannot open file

I've started learning how to use PHPUnit. However, I'm facing a problem which I have no clue how to solve.
I have a folder called lessons and inside there is a composer.json which I installed PHPUnit with.
The output resulted in a folder called vendor and a sub-folder called bin which has the phpunit file in it.
In the cmd I typed: cd c:/xampp/htdocs/lessons/vendor/bin. Now the cmd folder sets to the same folder as phpunit. I've created a directory in lessons which I called tests (lessons/tests) which I store all of my tests in. I've created a file called PracticeTest.php with a very simple test script in it.
When I go back to the cmd and type phpunit tests I get cannot open file tests.php When I try to type phpunit PracticeTest I get cannot open file PracticeTest.php. When I try phpunit tests/PracticeTest (with .php or without) I get the same error that the file could not be opened.
My suspicious that it has something to do with that face that the cmd is pointing at the lessons/vendor/bin directory, but I'm not sure if it is really the problem or how to fix it.
just to arrange the paths:
lessons\vendor\bin\
lessons\tests\
lessons\tests\PracticeTest.php
Thanks in advance!
Go to path project:
D:\>cd www
D:\wwww>cd lessons
And execute:
D:\www\lessons>vendor\bin\phpunit tests
PHPUnit 4.8.27 by Sebastian Bergmann and contributors.
.....E.
Time: 1.34 seconds, Memory: 5.50MB
There was 1 error:
1) UserTest::it_should_be_able_to_construct
PHPUnit_Framework_Exception: Argument #1 (No Value) of PHPUnit_Framework_Assert
:assertInstanceOf() must be a class or interface name
D:\www\lessons\tests\UserTest.php:10
FAILURES!
Tests: 7, Assertions: 4, Errors: 1.
It Works!!!!
This is what worked for me.
vendor/bin/phpunit ./tests/PracticeTest
I was getting the same, but if you type phpunit then tab you will see what directory you are in and it should autosuggest. Then navigate to your test file.
I had include_path sections separated by comma. It has to be semicolon on Windows.
I have created a phpunit.bat in the root folder of my project containing
#ECHO OFF SET BIN_TARGET=%~dp0/vendor/phpunit/phpunit/phpunit php "%BIN_TARGET%" %*
Now it works.

Doctrine Cli on Windows

I am having some trouble configuring doctrine orm on windows 8, php 5.4. I have installed Doctrine using Composer.
I have followed the docs to the letter but when I run any commands, php vendor/bin/doctrine orm:schema-tool:create for example, my command line just outputs
SRC_DIR="`pwd`"
cd "`dirname "$0"`"
cd "../doctrine/orm/bin"
BIN_TARGET="`pwd`/doctrine"
cd "$SRC_DIR"
"$BIN_TARGET" "$#"
I have also tried php vendor/bin/doctrine.php .... but it just prints out the above.
I have followed Doctrine's guide to the letter. Has anyone seen this before and if so, can you suggest anything?
i found a solution
there are also a bin folder in vendor/doctrine/orm/bin/ you can use this one like this
php vendor/doctrine/orm/bin/doctrine orm:schema-tool:create
make sure you have root folder and a cli-config.php file is present in root folder.
below is location where i found a solution
https://groups.google.com/forum/#!msg/doctrine-user/_ph183Kh-5o/_P_coljB-dcJ
this is working fine for me .
I had the same problem. The following solution worked for me:
"vendor/bin/doctrine.bat" orm:schema-tool:create
So, basically you:
use the ".bat" file provided by Doctrine and
enclose the call to that ".bat" file in quotes.
My Environment
Windows 7 Professional (x64)
PHP 5.5.12
Doctrine ORM 2.4.4
Do not write "php..." (it will write the file content)
Just "vendor\bin\doctrine orm:schema-tool:create" do the job (from the project root eg. c:\php\theProject).
Next, you will need a "cli-config.php" in the project root...
For Window version use backward slash "\"
vendor\bin\doctrine orm:schema-tool:create
not forward slash "/"
vendor/bin/doctrine orm:schema-tool:create
You can either install something like git bash or simply use the PHP version of the script:
php vendor\bin\doctrine.php orm:info
Obviously, the php binary directory should be in your PATH environment variable, otherwise, it's something like:
C:\path\to\php.exe vendor\bin\doctrine.php orm:info
Copy doctrine.bat (located at vendor/bin/doctrine.bat) to your project root directory
Create a bootstrap.php file in any path inside your project root directory with the following content:
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
$paths = array("../model");
$isDevMode = false;
$dbParams = array(
'driver' => 'pdo_mysql',
'host' => 'localhost',
'user' => 'root',
'password' => '',
'dbname' => 'angular_php',
);
$config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode);
$entityManager = EntityManager::create($dbParams, $config);
Create a cli-config.php file in your project root directory with the following content:
<?php
use Doctrine\ORM\Tools\Console\ConsoleRunner;
// replace with file to your own project bootstrap
require_once 'path/to/file/bootstrap.php';
return ConsoleRunner::createHelperSet($entityManager);
Execute from a command line window (CMD):
c:\path\to\project\root\directory>doctrine --help
It's done!
I found it wasnt returning anything from the doctrine.php.bat. Turns out it was a PHP error in my cli-config.php file
Using Cygwin on Windows with doctrine installed via composer, was having the same problem
resolved by:
vendor/bin/doctrine.bat orm:convert-mapping
if you are still having issues you can run the cli script using php to get the console tools running:
for example
php cli-config.php orm:schema-tool:create
All the answers on this question are either outdated or outright incorrect. In my case, I observed, after installing the the library, the "\vendor\doctrine\orm\" folder was completely empty. The docs ask you to run vendor/bin/doctrine, which in turn attempts to call "vendor\doctrine\orm\bin\doctrine[.php]" (The php file extension is optional). After discovering this, I downloaded the library from the git repository and replaced the composer-installed version.
php vendor/doctrine/orm/bin/doctrine
then works fine.
Also, beware of the common misconception that the cli-config.php file must exist in the root of your project. It's fine to leave it in your config folder

Categories