How to properly implement PHPWord to CakePHP? - cakephp

I am trying to generate a word document using phpword through cakephp but I always get a fatal error:
Error: Class 'PhpOffice\PhpWord\TemplateProcessor' not found
File:C:\xampp\htdocs\thesis\app\Controller\MainController.php
Line: 1016
line 1016:
$templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('resources/Sample_07_TemplateCloneRow.docx');
I placed the phpword files in this path:
C:\xampp\htdocs\thesis\app\Vendor
And the docx file here:
C:\xampp\htdocs\thesis\app\Vendor\PhpWord\resources
Is there anything wrong on how I implemented phpword with cakephp?
Thank you.

I think you should install PHPWord through Composer as CakePHP is using Composer to manage its dependancies.

Related

Testing after update: The plugin class `WyriHaximus\TwigView\Plugin` cannot be found

I started update CakePHP 3.5 to 3.6, but when I try check my code by tests, i got error:
InvalidArgumentException: The plugin class Migrations\Plugin cannot be found. Ensure your autoloader is correct.
After, I runed command php composer.phar require --dev phpunit/phpunit:"^5.7|^6.0"
Now a got next error:
InvalidArgumentException: The plugin class WyriHaximus\TwigView\Plugin cannot be found. Ensure your autoloader is correct.
And I don't used this plugin before.
Also I used this release files for update deprecated code
How I can fix it, and what could provoke this problem?
Full error:
3) App\Test\TestCase\Controller\CardsControllerTest::testEditPostError
InvalidArgumentException: The plugin class `WyriHaximus\TwigView\Plugin` cannot be found. Ensure your autoloader is correct.
C:\work\OSPanel\domains\project.loc\vendor\cakephp\cakephp\src\Http\BaseApplication.php:127
C:\work\OSPanel\domains\project.loc\vendor\cakephp\cakephp\src\Http\BaseApplication.php:95
C:\work\OSPanel\domains\project.loc\vendor\cakephp\bake\src\Plugin.php:50
C:\work\OSPanel\domains\project.loc\vendor\cakephp\cakephp\src\Http\BaseApplication.php:154
C:\work\OSPanel\domains\project.loc\vendor\cakephp\cakephp\src\Http\Server.php:124
C:\work\OSPanel\domains\project.loc\vendor\cakephp\cakephp\src\Http\Server.php:82
C:\work\OSPanel\domains\project.loc\vendor\cakephp\cakephp\src\TestSuite\MiddlewareDispatcher.php:149
C:\work\OSPanel\domains\project.loc\vendor\cakephp\cakephp\src\TestSuite\IntegrationTestCase.php:495
C:\work\OSPanel\domains\project.loc\vendor\cakephp\cakephp\src\TestSuite\IntegrationTestCase.php:392
C:\work\OSPanel\domains\project.loc\tests\TestCase\Controller\CardsControllerTest.php:229
Thank you.
Make sure you have removed/commented Plugin::routes(); line from your config/routes.php file.

CakePHP cms tutorial missing Helpers

Just starting with CakePHP and started the cms tutorial.
Install and configure went fine, but when I get to load the site for the first time there is a missing HTML Helper error.
When checking the View/Helper directory, it is empty: so obviously not installed.
What do I need to do to get the Helpers installed?
The issue was incorrect code in the ctp file (a stray character), and I incorrectly read the Error message as a missing Helper.
Core Helper was not actually missing, I just needed to read the Directory to discover the difference between core helpers and application helpers :-/

Not able to load Drupal site

I have downloaded a new theme from Themeforest however when loading the site I m getting the below error.
Even developer is confused about the error.
I believe its more of drupal issue can anyone help?
Fatal error: require_once(): Failed opening required 'C:\wamp\www\sites\all\modules\media\file_entity/file_entity.file_api.inc' (include_path='.;c:\wamp\bin\php\php5.4.12\pear') in C:\wamp\www\sites\all\modules\media\file_entity\file_entity.module on line 13
Can you try using relative path like
require_once("./file_entity.file_api.inc");
Before that you need to find out the getcwd() for getting the current working directory.'
then give relative path according to that.
OR
use below,
require_once(DRUPAL_ROOT . '/sites/all/modules/media/file_entity/file_entity.file_api.inc');

CakePHP Twitter plugin

Appologies if this is something obvious I've missed.
I'm trying to use this Cake plugin to add a twitter feed to my cake app (just display my latest tweet). I've followed the docs in the readme but I get this:
Missing Controller
Error: Twitter.UsersController could not be found.
Error: Create the class UsersController below in file: C:\wamp\www\mysite\app\Plugin\Twitter\Controller\UsersController.php
Heres what I've done so far (as the readme instructs):
Cloned all the files into app/Plugin/Twitter/
Rename Config/twitter.default.php to Config/twitter.php
Updated the config file with my twitter app keys
Visited mysite/twitter/twitter/connect - which gives me the above error.
The readme mentions that the plugin uses - http_socket_oauth, another cake plugin, I trust that this is included in this plugin and that I dont have to install that plugin aswel?
Could someone point me in the right direction?
Thank you

CakePHP Media Plugin Issue - undefined method MIME_Type::config()

I am using the Media plugin by David Persson for CakePHP (https://github.com/davidpersson/media). I've placed the files in app/plugins/media and added
require APP . 'plugins/media/config/core.php';
to my app's core.php, but when I run cake media init I get this error:
Fatal Error: Call to undefined method MIME_Type::config() in C:\xampp\htdocs\wompwomp\app\plugins\media\config\core.php on line 166
Any idea what's happening here? Can I just make the directories manually? If so, what are the default directories?
It looks like you need to install the MIME_Type library. The pear package for it is available here.
EDIT
The proper library would be found here.
I encounter this error on windows when i updated my php to 5.3.5 (xampp 1.7.4).
There is a conflict between Cakephp Mime Types and Pear Mime types. I rename the folder or
disable Pear Mime Type located at /php/PEAR/MIME..
That solves the problem.
Here is my solution to the conflict between the Plugin library and Pear library:
As we all known, the order of multiple php include_path matters, in other words, if the PEAR path is set before the Cake Media Plugin Built_In Mine_Type Library Path, the Mine_Type class in PEAR is found first, and the built-in one is ignored, that's the reason of the error.
To fix this, just open /app/plugins/media/config/core.php, and find the ini_set('include_path') directive, move the cake media plugin built-in library path to the very beginning of the INCLUDE_PATH.
That's it, enjoy!
Maybe someone can report this as a bug to the plugin author.

Resources