Mysql error when using Cake Bake - cakephp

H,
I am a newbie to cake php. So there is a problem i'm facing with.
I have installed XAMPP and my cakephp project folder lies in htdocs(/opt/lampp/htdocs/cakephp). When I start cake bake by the command /.cake bake, I am getting a mysql error as below.
enter code here
PHP Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /opt/lampp/htdocs/cakephp/cake/libs/model/datasources/dbo/dbo_mysql.php on line 552
can u help me?

Check if you have MySQL installed properly.

With XAMPP normally get this error.
You can do two things to solve it:
A clean installation of Apache + PHP + MySQL
If you're on a linux or on a mac you can create a symbolic link to the socket:
ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
Where /tmp/ is your XAMPP mysql folder (e.g. /opt/lampp/var/mysql/mysql.sock)

Related

How can I install cakephp2 in 2022?

can anyone tell me how can I install cakephp 2 in 2022 I tried many ways to install it I also have its zip file which I extract it and when I tried to run it it shows.
Fatal Error
Error: Cannot use 'String' as class name as it is reserved
File: E:\xampp\htdocs\cakephp2.3\lib\Cake\Utility\String.php
Line: 27
Notice: If you want to customize this error message, create app\View\Errors\fatal_error.ctp
CakePHP 2 needs php5
since Version 2.8 you can use php70
php71 is possible but you need to install mcrypt seperatly.
Its possible to run a CakePHP 2.8 on php72 with some core hacks. But i wouldn't recommend this.
I got my answer we can download its zip file from github and copy its file in htdocs folder and run it without an issue. By the way I downloaded cakephp 2.10. and it is also running in xampp with php version 8. If in your system it is not running then try to use xampp with php version 7.

Connect MS SQL with PHP 5.6 on Centos7

Im trying to connect a project to an MS SQL but I can't. I read a lot but no one answer helps me.
Now I´m trying with ADOdb with mssql driver but the connection answer is:
Missing extension for mssql
So I suppose I have to install it but I can't find how can do it for PHP 5.6 on Centos. Anyone?
Or maybe other way to reach the DB?
I already tried yum install php56-php-mssql, php56w-mssql but all of them are miss. And yum install php-mssql answer that package
is already installed
UPDATE
1) tsql test works
2) php-mssql connection in php also works WHEN RUN FROM THE SHELL
3) running PHP through apache does NOT work.
I found the mssql.so and added the path to my php.ini file, then restarted apache but when I load a page with phpinfo(), mssql.so doesn't show.
What is missing?
PROBLEM SOLVED
1) Download PHP5.6 source files.
2) go to php/ext/mssql
3) do phpize but with php used by Plesk located on /opt/plesk/php/5.6/bin/phpize
4) configure, make
5) copy generated *.so to extensions folder on /opt/plesk/php/5.6/lib64/php/modules
6) create /opt/plesk/php/5.6/etc/php.d/mssql.ini file with tho following text:
; Enable mssql extension module
extension=mssql.so
7) restart apache

Laravel sql server on mac

So i installed SQL serve with docker on mac and i can actually manage to access my local sql server database with datagrip, but when i want to do a php artisan migrate i get this error:
[Illuminate\Database\QueryException] could not find driver (SQL: select * from sysobjects where type = 'U' and name = migrations)
and this error
[PDOException]could not find driver
i search for some answer but they where mostly for linux.
So i manage to installed al the necessary drivers just by installing this:
https://github.com/Microsoft/msphpsql/releases
php and Laravel worked perfectly after i installed those package and added this lines on my php.ini file:
extension=sqlsrv.so
extension=pdo_sqlsrv.so
You need a module called "pdo_mysql". Try php_info()to see if it's installed - I doubt it's there.
In your php.ini file (you can find it via php --ini) uncomment the line which has extension=pdo_mysql.so on it and restart the server.
edit: also make sure that the default key is set in your config/database.php file. Something like 'default' => env('DB_CONNECTION', 'mysql'),

wamp phpinfo shows sqlsrv but phpinfo inside artisan server not showing sqlsrv drivers

I am using Apache 2.4.23 and Php 7.0.10 and Laravel 5.4.
I have installed sqlsrv and it's pdo file inside 'C:\wamp64\bin\php\php7.0.10' directory.
So when I created and test.php file in the www directory and executed it I got the following info.
The PDO Information
the SQLSRV info:
But when I start php artisan serve and execute phpinfo() then I didn't get the SQL drivers.
PDO extensions:
Drives SQL
So when I try to connect to SQL db I am getting this error.
QueryException in Connection.php line 647:
could not find driver (SQL: SELECT TOP 5 ......
Any help will be appreciated.
Thanks
WAMPServer has 2 php.ini files. If you want to add the SQLServer extension for use from the command line CLI then you must manually edit the
c:\wamp\bin\php\php7.0.10\php.ini
and add the new extension line
The extension dll's should be placed in the
c:\wamp\bin\php\php7.0.10\ext
folder.

Windows + Xampp + CakePHP - Composer throws error on update

I am trying to create a local development environment on a Windows machine using Xampp. Xampp has been setup correctly and I am able to access localhost, locahost/phpmyadmin and a virtual host I created domain.local. This Virtual Host is a CakePHP application that I had been running on a Linux Box (nginx). I use that code to setup the site, but when I try to run
php composer.phar update
to have composer download all dependencies, I get the following error:
Fatal error: Class 'Cake\Composer\Installer\PluginInstaller' not found in
phar://C:/Users/admin/Documents/Sites/domain.local/website/composer.phar/src/Composer/Plugin/PluginManager.php
on line 244
I have tried a bunch of things without success.
Also to note php composer.phar self-update, runs without issue.
Not sure what to do at this point. Any help is appreciated.
After more tryouts, I finally decided to delete the vendor folder and surprisingly it fixed my issue. Composer downloaded all dependencies and everything works as expected.

Resources