Trait 'Crud\Controller\ControllerTrait' not found in Cakephp - php

I transferred my cakephp api from linux vps to azure cloud. I configured redirects too but I am getting "Trait 'Crud\Controller\ControllerTrait' not found" error. I checked the bootstrap.php file to check whether its loading crud plugin or not. It does.
Do I need to run composer autoload to load the plugin? If yes then how to in azure as its windows vm.

Frist, you should check whether the folder named friendsofcake exists in \vendor directory or not. If not, you need to run the following command to install it by using composer:
composer require friendsofcake/crud:^4.3
Refer to this doc for more details.

I realised that my code base was created using composer version 1.
and to install all packages I had to run
composer install
However, not all plugins where loaded correctly. If you have composer version 2
installed and facing the issues
kindly run
composer update

Related

File ./vendor/autoload.php missing or not readable in phpmyadmin

This question is different from: https://stackoverflow.com/questions/36150377/missing-vendor-autoload-php
I want to contribute to phpmyadmin. I cloned the github repo in my machine using Github Desktop software. I copied the downloaded files in xampp so that I can run phpmyadmin. But when I launch the phpmyadmin page, this error occurs:
File ./vendor/autoload.php missing or not readable.
Most likely you did not run Composer to install library files.
Where can I get that file? I saw something that uses composer create-project command but I don't get that where should I type that command?
I also downloaded phpmyadmin from their website and copy pasted in xampp directory and it worked well. It didn't give any such error.
What should I do?
This changed as of v4.7.0
https://www.phpmyadmin.net/files/4.7.0/
Starting with this version, phpMyAdmin uses Composer to manage PHP library dependencies while under development.
Users downloading the official source distribution will not notice a difference, however users of the git repository
should refer to https://docs.phpmyadmin.net/en/latest/setup.html#installing-from-git for details.
Here's the change PR for those interested: github.com/phpmyadmin/phpmyadmin/pull/11976
When you download or clone phpMyadmin it's missing the vendor folder, which is installed by Composer.
Open the phpMyadmin folder and run the composer install command. This will download and install third party dependencies and generate the vendor/autoload.php file.

Laravel Composer Update Changed Files

I need to discus a very important thing for me (probably for all users who uses composer in their projects). I am working on laravel. Whenever i work on my local machine, i run composer update after adding new library in vendor.
Now it works fine on local machine. But when i upload these files on my server, it shoots error like "Undefine class ....". I dont know how to run composer update command on server (Also it might be not safe).
So may i just know which files are updated by using composer update on cmd. What other files needed to go live to avoid this error??
You may:
Run composer update on your local server only, whenever you want.
Commit/push every files (including composer.lock) but the vendor directory
Deliver to your production server (without vendor, with composer.lock)
Then run composer install on your production server. It will update all your dependencies according to your composer.lock(so the exact same versions as your last update on your local server).
So in other words: you should not run composer update on your server, just composer install on every delivery (and you will need to keep your composer.lock)
Hope it will help you.
run composer dump-autoload before composer update. If still doesn't work then try to clear composer cache using composer clear-cache
composer update will update the version of every package from you vendor folder.
normally if you can not ensure you need update all the version of every package, you should use composer install
the reason of error "undefined class" is normally caused from app.php.Because service provider is defined in app.php, but the class(package) not been installed.
in order to solve your problem, try do this in three ways:
composer install --no-scripts;
comment the service providers which not been installed already from app.php, then composer install
composer dump-autoload

Composer BowerPHP Error

I am trying to install BowerPHP in my Laravel framework project on my computer using Composer. I have used the composer require "beelab/bowerphp 0.3.*#beta" command in the command prompt but I'm receiving errors:
Can only install one of : symfony/process[v2.7.9,v3.0.2]
Can only install one of : symfony/process[v2.7.8,v3.0.2]
Can only install one of : symfony/process[v2.7.7,v3.0.2]
etc.
From what I understand my framework already has a version of Symfony and I cannot download another package. In addition, the package that I have is not compatible with BowerPHP. What do I do? And am I correct?
So I found the answer. The beelab team did not update their own website but did update their github page. running the composer require beelab/bowerphp:1.0.*#dev would work but running the on on their website would not.

bash: laravel: command not found

I am Using my own Machine Kali Linux 2.0 Debian x64 . Now, i have Installed Laravel in my directory structure like
/opt/lampp/htdocs/learning-larvel/
Inside the Learning-laravel folder i have Installed my Laravel files, and also i installed composer. So when i go to http://127.0.0.1/learning-laravel/public . I see a See a White Screen and in Between it is written "Laravel 5", which means the Laravel GUI Setup is fine.
Now, to create a new file for Laravel, when i open my Terminal and type
laravel new xyz
then it gives me a error which says bash: laravel: command not found
Now, how can i fix the error.. I have researched about it by setting PATH to bashrc. But i am not getting it fixed right. Additionally when i type in my command composer -version then also it says bash: composer: command not found but i have Installed composer on the folder learning-laravel itself.
I could also see files like composer.phar there in /opt/lampp/htdocs/learning-larvel/
Any help would be extremely thankful.
As the composer official getting started page points out:
There are in short, two ways to install Composer. Locally as part of
your project, or globally as a system wide executable.
if you wanna do composer -- or laravel -- in command line, you wanna install them globally.
Check out the following links:
https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx
https://laravel.com/docs/4.2#install-laravel
I encountered the same problem. Apparently, the composer exists in path ~/.config/composer/vendor/bin when running as super user. Therefore, replacing the paths which were described above by this, and it should work. Hope it helps.

installing cakephp 3 manually, without composer

I need to install CakePHP 3 in an old-fashioned upload-unzip-run way.
The archive I've downloaded from cakephp/cakephp/tags does not contain the default folders like webroot, Model etc., which means it's not complete.
The official documentation does not cover this. Here's a relevant Github issue I found, but the person ends up still using Composer.
There's also cakephp/app and it seems to include those missing files, but it's not mentioned in cakephp/cakephp's composer.json, and even if I download it I've no idea how to merge the packages.
Packaged app (cakephp/app) releases that include all dependencies (framework (cakephp/cakephp), standard CakePHP plugins (cakephp/debugkit, cakephp/bake, etc), required third party libraries) can be found on GitHub.
https://github.com/cakephp/cakephp/releases
It's the download with the small package symbol, named like cake-3-x-x.zip.
However, it isn't a good idea to ditch the dependency manager, as keeping the code base and the autoloader up to date will be rather tedious, and, no offense, I have my doubts that you'll be able to handle this properly if you don't even know how to stitch the app and cake packages together.
You can install CakePhp 3 without Composer.
You need minimum requirements to install CakePhp 3 and CakePhp 3 boilerplate ( fresh copy of Cakephp 3 ).
You can download CakePhp 3 boilerplate from github.
Requirements
Server
HTTP Server. For example: Apache. Having mod_rewrite is preferred,but by no means required.
PHP 5.4.16 or greater.
mbstring extension
intl extension
Database :
MySQL (5.1.10 or greater)
PostgreSQL
Microsoft SQL Server (2008 or higher)
SQLite 3
All built-in drivers require PDO. You should make sure you have the correct PDO extensions installed.
CakePhp 3 Boilerplate:
Repository Home
https://github.com/cakephp/cakephp/releases
CakePhp 3.1.4
https://github.com/cakephp/cakephp/releases/download/3.1.4/cakephp-3-1-4.zip
CakePhp 3.0.15
https://github.com/cakephp/cakephp/releases/download/3.0.15/cakephp-3-0-15.zip
Download one repository and unzip where you wanted to install it.
You may get one error like ( you may not get error if you are lucky!)
Fatal Error
Cake\Error\FatalErrorException
Error: Class 'Cake\Mailer\Email' not found
File D:\xampp\htdocs\practice\cakephp\cakephp-3-1-4\config\bootstrap.php
Line: 138
Then you have to comment two line in config/bootstrap.php
//Email::configTransport(Configure::consume('EmailTransport'));
//Email::config(Configure::consume('Email'));
And finally you got CakePhp 3 installed.
[I am also new in CakePhp 3.So Please inform me if there are any wrong in my given process.]
Thanks
Use Composer.
Install Composer locally, follow the Cake installation instructions, then upload the created folders to the target webhost.
Easy, For CakePHP 3.x you can just download the release you want from here
https://github.com/cakephp/cakephp/releases (eg. https://github.com/cakephp/cakephp/releases/tag/3.3.16).
For a complete installation select the first download link (.zip)
the other links are just for the src
Just run this command to get a clone of CakePHP 3.10.0
git clone -b 3.x git://github.com/cakephp/cakephp.git
Try simple steps
1. Download XAMPP Server.
2. Install XAMPP server.
3. Go to ..\xampp\php\php.ini and open.
4. Add this line (extension=php_intl.dll) or if exist uncomment.
5. Download Composer setup from https://github.com/composer/windows-setup/releases/
6. Install composer and give php.exe file in path
7. Open cmd and check now php version using command php -v. if its showing php version its means its working.
8. Now open cmd and cd on xampp\htdocs folder & run command composer create-project --prefer-dist cakephp/app app_name
9. Finished folder created in htdocs.

Categories