Laravel route not found when route exists - php

When I try to access my laravel site I get this error in the console.
Laravel development server started: <http://127.0.0.1:8000>
[Mon Nov 16 10:39:15 2020] PHP Fatal error: Uncaught InvalidArgumentException: Route [home] not defined. in /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php:389
Stack trace:
#0 /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(822): Illuminate\Routing\UrlGenerator->route('home', Array, true)
#1 /Users/threeaccents/code/src/gitlab.com/few/bodylove/storage/framework/views/e071ac62e490c49233841ae8b6b3906075bc0187.php(6): route('home')
#2 /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php(43): include('/Users/threeacc...')
#3 /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(59): Illuminate\View\Engines\PhpEngine->evaluatePath('/Users/threeacc...', Array)
#4 /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/View/View.php(142): Illuminate\Vi in /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php on line 389
[Mon Nov 16 10:39:15 2020] PHP Fatal error: Uncaught InvalidArgumentException: Route [home] not defined. in /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php:389
Stack trace:
#0 /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(822): Illuminate\Routing\UrlGenerator->route('home', Array, true)
#1 /Users/threeaccents/code/src/gitlab.com/few/bodylove/storage/framework/views/e071ac62e490c49233841ae8b6b3906075bc0187.php(6): route('home')
#2 /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php(43): include('/Users/threeacc...')
#3 /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(59): Illuminate\View\Engines\PhpEngine->evaluatePath('/Users/threeacc...', Array)
#4 /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/View/View.php(142): Illuminate\Vi in /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php on line 389
But route home is clearly defined. I even set it at the top of my route file to make sure nothing else was overriding it.
routes/web.php
<?php
// New Home Page for App
Route::get('/', 'Web\HomeController#index')->name('home');
...
with php artisan route:list
+--------+----------------------------------------+--------------------------------------------------------------------------------------------+--------------------------------------------+------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+----------------------------------------+--------------------------------------------------------------------------------------------+--------------------------------------------+------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| | GET|HEAD | .well-known/apple-developer-merchantid-domain-association | | App\Http\Controllers\Web\ApplePayDomainVerificationController | web |
| | GET|HEAD | / | home | App\Http\Controllers\Web\HomeController#index | web |
Update
I've cleared route cache, deleted vendor folder, re-installed PHP but nothing seems to solve the issue.
I've tried it on my work laptop (same setup) and everything works. It seems to be an issue with my current station but I'm not sure what would be causing it. I'm using PHP 7.2 on a mac os 10.14.4. Laravel 5.7
I also thought maybe it was an overall system issue but if I create a new laravel project everything works as expected so it does seem to be a project specific issue.

It was an issue with my apache config. It seems on my latest brew update apache got updated and the config file changed a bit. I had to change
#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
AllowOverride none
Require all denied
</Directory>
to
<Directory />
AllowOverride all
Require all granted
</Directory>

Route like that is doesn't work except you edit the RouteServiceProvider
There is new version of laravel, please make sure you upgrade your PHP or XAMPP and try to update the composer global laravel and last create a new laravel project.
See Laravel documentation
And this post
https://youtu.be/MfE1tnMG6fE

You can remove name('home'), because error is Route [home] not defined
<?php
// New Home Page for App
Route::get('/', 'Web\HomeController#index');

Related

Laravel macOS Unexpected character in input: '

i installed Vagrant on my macOS with the Parallels provider.
I created a new project with the command laravel new blog.
When i opened the site everything works fine. Then i want to add an auth with these commands: php artisan make:auth php artisan migrate
The first command works fine but the second produces errors:
PHP Warning: Unexpected character in input: ' in /home/vagrant/blog/routes/web.php on line 17
I figured out that the problem is between the vagrant box "homestead" and macOS. Because after i turned off the sync between homestead and macOS and reinstalled the whole project it worked fine. So can you tell me where the problem is? Is it the charset?
This is what my web.php looks like (i made no changes):
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function () {
return view('welcome');
});
Auth::routes();
Route::get('/home', 'HomeController#index')->name('home');
It happened to me also. Enabling NFS solved my problem. Not sure what is the cause.
Homestead.yaml
folders:
- map: ~/code
to: /home/vagrant/code
type: "nfs"
If somebody still running into this problem,the solution for me was:
Exit from vagrant ,and once out of it, reload the vagrant VM and enter again to your project folder and run:
composer dump-autoload
php artisan migrate
After that ,im not getting the error and the column in my case is being created in the DB table

Laravel 5 / Apache 2.4.9 Configuration problems

I am trying to install and configure Laravel 5 on a CentOS brand new server.
But I am afraid I don't have enough knowledge to understand and fix what is wrong with my environment. So I will try to describe as accurate as I can my actual setup and problems.
Let's start with Apache 2.4.9
Everything in the httpd.conf is almost default. I just edited the document root path to point directly at the future laravel public folder:
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/usr/local/apache/htdocs/public"
<Directory "/usr/local/apache/htdocs/public">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options -Indexes -FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
Require all granted
And before you ask, yes the mod_rewrite module is enabled.
Then my PHP also has basic configuration and it's version is 5.6.15.
Then I installed composer and used it to create a new laravel project
composer create-project laravel/laravel {directory} "~5.0.0" --prefer-dist
Everything successfully ran with no issues.
But now I try to visit my freshly installed laravel app by entering my server IP address but it only displays a blank page and if I check the console it gives me an 500 error.
So here is in order what I did to try to fix the problem:
I found a post on the laravel blog that said we should give full right to the /storage folder which I did and now I don't have a white page anymore but instead I have the: 'whoops something went wrong' error.
I try the alternate .htaccess config file suggested on the official laravel doc - nothing changed
I don't why exactly I did this but I ran the php artisan serve command and now I see the Laravel welcome page... even if I exit the serve mode it still runs ?!? I am not sure if I understand why but even if I did it actually doesn't work completely... I only get the welcome page but if I try http://my-ip-address/home it shows me a 404 not found.
I feel like I have searched everywhere but yet I couldn't find an answer and I am close to the depression. Does anyone here has any clues about my problem ?
Thanks to anyone who can help me with this !
#update
Sorry I forgot the server logs:
[2015-12-17 04:22:03] production.ERROR: exception 'ReflectionException' with message 'Class encrypter does not exist' in /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Container/Container.php:776
Stack trace:
#0 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Container/Container.php(776): ReflectionClass->__construct('encrypter')
#1 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Container/Container.php(656): Illuminate\Container\Container->build('encrypter', Array)
#2 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(613): Illuminate\Container\Container->make('encrypter', Array)
#3 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Container/Container.php(887): Illuminate\Foundation\Application->make('Illuminate\\Cont...')
#4 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Container/Container.php(848): Illuminate\Container\Container->resolveClass(Object(ReflectionParameter))
#5 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Container/Container.php(813): Illuminate\Container\Container->getDependencies(Array, Array)
#6 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Container/Container.php(656): Illuminate\Container\Container->build('Illuminate\\Cook...', Array)
#7 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(613): Illuminate\Container\Container->make('Illuminate\\Cook...', Array)
#8 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(127): Illuminate\Foundation\Application->make('Illuminate\\Cook...')
#9 /usr/local/apache/htdocs/public/index.php(57): Illuminate\Foundation\Http\Kernel->terminate(Object(Illuminate\Http\Request), Object(Symfony\Component\HttpFoundation\Response))
#10 {main}
[2015-12-17 04:22:03] production.ERROR: exception 'ErrorException' with message 'file_put_contents(/usr/local/apache/htdocs/vendor/services.json): failed to open stream: Permission denied' in /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Filesystem/Fi$
Stack trace:
#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'file_put_conten...', '/usr/local/apac...', 74, Array)
#1 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php(74): file_put_contents('/usr/local/apac...', '{\n "provider...', 0)
#2 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php(193): Illuminate\Filesystem\Filesystem->put('/usr/local/apac...', '{\n "provider...')
#3 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php(139): Illuminate\Foundation\ProviderRepository->writeManifest(Array)
#4 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php(59): Illuminate\Foundation\ProviderRepository->compileManifest(Array)
#5 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(439): Illuminate\Foundation\ProviderRepository->load(Array)
#6 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/RegisterProviders.php(15): Illuminate\Foundation\Application->registerConfiguredProviders()
#7 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(167): Illuminate\Foundation\Bootstrap\RegisterProviders->bootstrap(Object(Illuminate\Foundation\Application))
#8 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(195): Illuminate\Foundation\Application->bootstrapWith(Array)
#9 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(106): Illuminate\Foundation\Http\Kernel->bootstrap()
This is the 2 errors I get.
Sorry I couldn't add a comment.
I think you might be missing the php-mcrypt extension.
First generate key for laravel 5.1 application using below command.
e.g.
$ php artisan key:generate
Application key [Idgz1PE3zO9iNc0E3oeH3CHDPX9MzZe3] set successfully.
Now copy this key and paste it in yourproject/config/app.php
'key' => 'Idgz1PE3zO9iNc0E3oeH3CHDPX9MzZe3',
Try this:
sudo chmod 775 /usr/local/apache/htdocs/vendor/services.json
Sorry, I haven't replied during the weekend, I was a bit busy.
Everybody had a bit of right in their answers. It was definetlely directories permission problem. I haven't found yet the perfect level of permission because I am not an expert. But I can tell you if I chmod -R 777 /storage /vendor and /public it works.
I know chmod 777 is probably insecure but I am really not an expert in permissions..
But anyway I'll mark this answer as solved because I indeed solved my problem in a way :)
But if anybody has a better answer or would like to give a more detailled explanation I'll update this post or mark the best answer as solved.

unable to live site in server laravel5

iam getting an error after uploaded project to server. when i visited to link somedomain.com/DEMO i got following error. What actually is this error? how can i solve it please help me.
Warning: require(/home/siddins/public_html/DEMO/project/app/http/helpers/backend/helpers.php): failed to open stream: No such file or directory in /home/siddins/public_html/DEMO/project/vendor/composer/autoload_real.php on line 54
Fatal error: require(): Failed opening required '/home/siddins/public_html/DEMO/project/app/http/helpers/backend/helpers.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/siddins/public_html/DEMO/project/vendor/composer/autoload_real.php on line 54
my index.php is like this:
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* #package Laravel
* #author Taylor Otwell <taylorotwell#gmail.com>
*/
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels nice to relax.
|
*/
require __DIR__.'/project/bootstrap/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
$app = require_once __DIR__.'/project/bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/
$kernel = $app->make('Illuminate\Contracts\Http\Kernel');
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
project is main folder . Inside projetc i have app,vendor,bootstrap,config,database,resources etc
Here are some of the best practices while launching a Laravel app on server.
Try them out. Might solve your issues. These steps have solved almost every problem that I have faced till now while launching a site on server.
1.Enable Mod_Rewrite
a2enmod rewrite
2.Install php 5.6
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php5-5.6
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install php5
While returning views, always use Foldername.viewname instead of Foldername\viewname
use public_path() while including files
chmod -R 777 "Storage folder path"
This file doesn't exist:
/home/siddins/public_html/DEMO/project/app/http/helpers/backend/helpers.php

Different behavior of PHP’s include/require on Windows and CentOS

These are code of my PHP applications myApp.phpand mypartsA/main.php.
myApp.php
<?php
echo ("##### myApp is starting now !!! </br>");
require_once('/parts/mypartsA/main.php');
?>
mypartsA/main.php
<?php
echo ("#### mypartsA is required </br>");
?>
And myApp.php and mypartsA/main.php are in following structure.
Document_root
|
+--- test
| |
| +--- myApp.php
|
+--- parts
|
+--- mypartsA
|
+---main.php
I’ve used this application on Windows+Apache for a year with no problem but recently I migrate this to CentOS+Apache then I get fatal error related to include_path
PHP Warning: require_once(/parts/mypartsA/main.php)
[<a href='function.require-once'>function.require-once</a>]
: failed to open stream
: No such file or directory
in /var/www/html/test/myApp.php on line 12
PHP Fatal error: require_once() [<a href='function.require'>function.require</a>]
: Failed opening required (/parts/mypartsA/main.php’
(include_path='.:/php/includes:/usr/share/pear:/usr/share/pear/PEAR:/var/www/html')
in /var/www/html/test/myAPP.php on line 12
According to PHP.net if a path is defined the include_path will be ignored.
http://www.php.net/manual/en/function.include.php
I think in my case PHP tries to find parts directory from C:\ or / not from include_path.
require_once(/parts/mypartsA/main.php);
Therefore result of myAPP.php must be fatal error whether on Windows or on CentOS.
But my application has been working for a year with no error on Windows. PHP can find parts directory correctly.
Can sameone try those codes above on Windows and see..
##### myApp is starting now !!!
#### mypartsA is required
or get error?
Now,I want to know is why results of same code are different between running on Windows and running on CentOS.
What dirctive in PHP.ini do I have to check ?
I know if I change this code to add absolute path with $ _SERVER['DOCUMENT_ROOT'].
require_once($_SERVER['DOCUMENT_ROOT']./parts/mypartsA/main.php);
It’ll work well. But there are many applications with same style of coding and I don’t want to change all of them.
These are additional information.
include_path values phpinfo() shows on Windows
.;C:\PHP;C:\PHP\pear;C:\Apache2.2.22\htdocs
include_path values phpinfo() shows on CentOS
.:/php/includes:/usr/share/pear:/usr/share/pear/PEAR:/var/www/html
$path = realpath(dirname(__FILE__)) . "/../../parts/mypartsA/main.php";
require_once($path);
try with this path
$path = "../parts/mypartsA/main.php";
the second path should work with document root.

cake console 2.2.1: Bake errors

OSX machine running MAMP. CakePHP 2.2.1 installed and configured properly (meaning that I have all green bars when I browse to the Index.php file, I have completed the Blogs tutorial and am working on my second app with which scaffolding is up and running). Now I am trying to Bake for the first time.
Per the cookbook (and others), I installed a fresh copy of cake into a directory (my users directory) and then put the path variable in my .bash_profile file
export PATH="$PATH:/Users/p_scott/cake221/app/Console"
after which I was able to go into Terminal, type cake and have the console come up. You can see that up to that point, I was invoking the console from the app directory.
I first tried running cake bake from the terminal using the -app parameter and designating the path to my practice apps. The first time I did this, I got the following
Welcome to CakePHP v2.2.1 Console
-------------
App : app
Path: /Applications/MAMP/htdocs/blog/app/
-------------
Interactive Bake Shell
---------------
[D]atabase Configuration
[M]odel
[V]iew
[C]ontroller
[P]roject
[F]ixture
[T]est case
[Q]uit
What would you like to Bake? (D/M/V/C/P/F/T/Q)
> c
--------------------
Bake Controller
Path: /Applications/MAMP/htdocs/blog/app/Controller/
--------------------
\Use Database Config: (default/test)
[default] >
No matter what I put in for the database (if I leave it blank, it asks me again), but any answer gives me the following error:
Warning Error: PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in [/Users/p_scott/cake221/lib/Cake/Model/Datasource/Database/Mysql.php, line 149]
Error: Database connection "SQLSTATE[HY000] [2002] No such file or directory" is missing, or could not be created.
#0 /Users/p_scott/cake221/lib/Cake/Model/Datasource/DboSource.php(260): Mysql->connect()
#1 /Users/p_scott/cake221/lib/Cake/Model/ConnectionManager.php(101): DboSource->__construct(Array)
#2 /Users/p_scott/cake221/lib/Cake/Console/Command/Task/ModelTask.php(906): ConnectionManager::getDataSource('default')
#3 /Users/p_scott/cake221/lib/Cake/Console/Command/Task/ControllerTask.php(396): ModelTask->getAllTables('default')
#4 /Users/p_scott/cake221/lib/Cake/Console/Command/Task/ControllerTask.php(419): ControllerTask->listAll(NULL)
#5 /Users/p_scott/cake221/lib/Cake/Console/Command/Task/ControllerTask.php(136): ControllerTask->getName()
#6 /Users/p_scott/cake221/lib/Cake/Console/Command/Task/ControllerTask.php(61): ControllerTask->_interactive()
#7 /Users/p_scott/cake221/lib/Cake/Console/Command/BakeShell.php(113): ControllerTask->execute()
#8 /Users/p_scott/cake221/lib/Cake/Console/Shell.php(393): BakeShell->main()
#9 /Users/p_scott/cake221/lib/Cake/Console/ShellDispatcher.php(201): Shell->runCommand(NULL, Array)
#10 /Users/p_scott/cake221/lib/Cake/Console/ShellDispatcher.php(69): ShellDispatcher->dispatch()
#11 /Users/p_scott/cake221/app/Console/cake.php(33): ShellDispatcher::run(Array)
#12 {main}
Once I started getting this error, I tried navigating in terminal to the <cake install dir>/app/Console folder and the <different instance of cake install dir>/app/Console folder to try the console from within my app/s. I either get the same errors or it asks me different questions, like:
What is the path to the project you want to bake?
[/Users/p_scott/myapp] > /Applications/MAMP/htdocs/history/app
What is the path to the directory layout you wish to copy?
[/Applications/MAMP/htdocs/history/lib/Cake/Console/Templates/skel] >
PHP CLI is installed and it appears to be working
PHP 5.3.8 (cli) (built: Dec 5 2011 21:24:09)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
My PDO support appears to be enabled. In terminal I typed:
php --ri pdo
PDO
PDO support => enabled
PDO drivers => mysql, sqlite, sqlite2
I don't have a php.ini file in Apache (because I am on a Mac), but the one in the PHP 5.36 directory, I have the following extensions enabled:
extension=imap.so
extension=yaz.so
extension=mcrypt.so
extension=gettext.so
extension=pgsql.so
extension=pdo_pgsql.so
extension=pdo_mysql.so
After taking a break, I found an article
(http://www.dereuromark.de/2011/10/31/freshly-baked-cake2-0-tips/) that talks about a change of console location in 2.0. I should try using it from that location (<cake installed dir>/lib/Cake/Console ). Once I tried this, I either got the questions about what layout I wanted to use or... ONCE, I was able to get the bake application to ask me to create a database configuration. I went through the steps and it pooped out this error at the end:
Fatal error: Class 'DATABASE_CONFIG' not found in /Applications/MAMP/htdocs/history/lib/Cake/Console/Command/Task/DbConfigTask.php on line 264
Which leads me to one more piece of info. This is my default DB configuration in the <cake installation dir>/history/app/Config/database.php file.
class DATABASE_CONFIG {
public $default = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'cakeHistoryUser',
'password' => 'cakeHistoryPassword',
'database' => 'cake_history',
'prefix' => '',
//'encoding' => 'utf8',
);
Before posting this question (and all of this information), I spend some quality time out here and it seems like most of my issues are or CLI related but I just don't see where I need to change something and hours and hours later, I need some help.
Help me Obi Wan, you are my only hope
The problem is you are trying to interact with the database via the command line, however the PHP-CLI is a different install than the one proveided by MAMP so it doesn't know about the database server.
Try changing localhost to 127.0.0.1 in your app/Config/database.php file and that should do the trick.
Something like this happened to me, and the easiest way I found to make it work which I don't see here is changing localhost to 127.0.0.1 and adding the port number at the end, e.g., MAMP uses port number 8899, so:
"mysql:host=127.0.0.1:8889"

Categories