I am working on a project in Yii2 where I need to integrate CKEditor. I used this to install it:
composer require 2amigos/yii2-ckeditor-widget
It downloads the library files under /vendor directory. When I copied the files from local to server and used this:
use dosamigos\ckeditor\CKEditor;
<?= $form->field($userSurveyConfig,
'survey_email_body')->widget(CKEditor::className(),
['options' => ['rows' => 6],'preset' => 'basic'])
?>
When I run the page, this error pops up:
> Class 'dosamigos\ckeditor\CKEditor' not found
What i am doing wrong here? Any help?
Copy composer.json file to server and run composer update on server.
Related
I worked on a team and then clone the laravel/php codes from our repository. When I serve the laravel on localhost, it cannot find all the file inside the public directory and throw an error on the terminal:
[404]: GET /public/css/style.css - No such file or directory
Many answers to similar issues advise me to change the codes in the blade.php file. The problem is that I can't edit the blade.php because it works fine on other team members even though we have the same ubuntu, PHP, and laravel version and .env file.
What I have tried:
Run composer install and composer update
Try different browsers such as firefox and chromium-based browsers
Run php artisan storage:link
Restart apache2
Run npm install and npm run dev
I think there is some package or something missing.
List of paths I get from dd($__data):
"path" => "/project-directory/project-name/app"
"path.base" => "/project-directory/project-name"
"path.lang" => "/project-directory/project-name/resources/lang"
"path.config" => "/project-directory/project-name/config"
"path.public" => "/project-directory/project-name/public"
"path.storage" => "/project-directory/project-name/storage"
"path.database" => "/project-directory/project-name/database"
"path.resources" => "/project-directory/project-name/resources"
"path.bootstrap" => "/project-directory/project-name/bootstrap"
Have you tried?
php artisan storage:link
You need first run
php artisan storage:link
For more details check https://laravel.com/docs/8.x/filesystem
Then you must be check your .env values.
Is correctly APP_URL=
Also in your exception is strange
/public/.../...
Reason is wrong configuration.
First check your .env values like
APP_URL=...
FILESYSTEM_DRIVER=public
then check config/filesystems.php
Encountered the following error in My Laravel app:
FatalErrorException in CollaboPDFController.php line 14: Class 'PDF' not found
This is my CollaboPDFController.php:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use PDF;
class CollaboPDFController extends Controller
{
public function getPDF(){
$pdf = PDF::loadView('customer.customer'); //line 14
return $pdf->download('customer.customer');
}
//
}
How I can fix this?
You are using the wrong import. To use the PDF you want (probably laravel-dompdf) use:
use Barryvdh\DomPDF\Facade as PDF;
If you put 'PDF' => Barryvdh\DomPDF\Facade::class, in your config/app.php you could also use:
use \PDF;
or
\PDF::loadView('customer.customer');
First you have to require DOMPDF package
Step 1 :
composer require barryvdh/laravel-dompdf
Step 2 : In ..\config\app.php
'providers' => [
.....
Barryvdh\DomPDF\ServiceProvider::class,
],
'aliases' => [
.....
'PDF' => Barryvdh\DomPDF\Facade::class,
]
Step 3 :
use \PDF;
Step 4 :
$pdf = PDF::loadView('pdf.report');
return $pdf->stream('report.pdf', array('Attachment' => 0));
You can run following commands after installing dompdf and set service provider and aliases in this file config/app.php
php artisan cache:clear and php artisan config:cache
Run the below command
composer require barryvdh/laravel-dompdf
In my case, I tried some of the examples above, but nothing worked.
However, I browsed the directory of the package located here:
project-folder>vendor>barryvdh>laravel-dompdf>src>Facade>Pdf.php
and I realized that the PDF alias created in the file >> app.php does not use the correct class.
So replace:
'aliases' => [
.....
'PDF' => Barryvdh\DomPDF\Facade::class,
]
by:
'aliases' => [
.....
'PDF' => Barryvdh\DomPDF\Facade\Pdf::class,
]
I hope this will help you.
finally got the solutions actually it was My domPDF installation problem I find out it this way
php artisan cache:clear
// and
php artisan config:cache
and install domPDF again
this is problem with cache config.php within bootstrap folder.
shared hosting does not show full path of your [project folder]in shared hosting and if you want clear cache , you have to purchase their plugins. by the given solution you have no need to purchase any plugin or no need to clear / config cache of laravel 5.6 or more.
hit the URl in your browser it will give you error log. now oprn your error log and copy the path from the error log.
change all file paths in config.php of [your project folder ]/bootstrap/cache, [your project folder ]\bootstrap\cache or [your project folder ]* etc by the full path copied from error log like /mnt/stor2-wc1-dfw1/411797/622471/[yourdomain]/web/content/[your project folder ]
Class 'Illuminate\Html\HtmlServiceProvider' not found laravel 5.0
Simply follow 4 step
1) Go root directory find and edit composer.json - In that file write "illuminate/html": "^5.0" in require array.
2) Goto cmd and goto your folder directory and ** composer update **run this command
3) Next, add your new provider to the providers array of config/app.php:
'providers' => [
'Collective\Html\HtmlServiceProvider',
],
4) Finally, add two class aliases to the aliases array of config/app.php:
'aliases' => [
'Form' => 'Collective\Html\FormFacade',
'Html' => 'Collective\Html\HtmlFacade',
],
After all this finished
Restart your laravel server :-- php artisan serve --port=8880
Now you can use Any Html tag in your view blade
For me, it was a much stupider mistake that I was making (although the provided answer works perfectly for the real issue).
What I was doing was continually editing the wrong composer file. I had one composer file outside of my laravel directory that was obviously not going to make any difference in my application.
When I did all of the recommended updated to the real composer file, everything worked fine.
I downloaded the yii2-jui in this link
yii2-jui
After that I put it under yiisoft folder
yiisoft\yii2-jui
when I run my application it gives me this error
PHP Fatal Error – yii\base\ErrorException
Class 'yii\jui\DatePicker' not found
How can I fixed this.where should I put the yii2-jui folder ?
Thank you in advance
I fixed the problem when I ran
sudo composer require --prefer-dist yiisoft/yii2-jui "*"
ONLY IN FOLDER basic, where are web, yii, models and etc.
Insert this in the view:
use yii\jui\DatePicker;
The best way is: run: php composer.phar require --prefer-dist yiisoft/yii2-jui "*" in your project
insert code:
'yiisoft/yii2-jui' =>
array (
'name' => 'yiisoft/yii2-jui',
'version' => '2.0.2',
'alias' =>
array (
'#yii/jui' => $vendorDir . '/yiisoft/yii2-jui',
),
),
in yiisoft/extensions.php file
Stop creating duplicate questions.
And you do not just download something and copy it in a folder. Use composer to install it. the Yii2 that you copied is just a shell, you have to use composer to install the rest of it. Composer does more then just copy the files it creates an autoloader that tells yii where everything is.
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