1
votes

I'm trying to use cake bake to scaffolding my project but when it goes generate the views I get this errors messages:

Warning Error: dirname() expects parameter 1 to be string, array given in [/Applications/MAMP/htdocs/apeppers/romeo2/lib/Cake/Utility/File.php, line 89]

Warning Error: is_dir() expects parameter 1 to be a valid path, array given in [/Applications/MAMP/htdocs/apeppers/romeo2/lib/Cake/Utility/File.php, line 90]

Warning Error: basename() expects parameter 1 to be string, array given in [/Applications/MAMP/htdocs/apeppers/romeo2/lib/Cake/Utility/File.php, line 91]

Notice Error: Undefined property: File::$table in [/Applications/MAMP/htdocs/apeppers/romeo2/lib/Cake/Model/Model.php, line 1054]

Notice Error: Undefined property: File::$primaryKey in [/Applications/MAMP/htdocs/apeppers/romeo2/lib/Cake/Console/Command/Task/ViewTask.php, line 464]

Notice Error: Undefined property: File::$displayField in [/Applications/MAMP/htdocs/apeppers/romeo2/lib/Cake/Console/Command/Task/ViewTask.php, line 465]

Fatal error: Call to undefined method File::schema() in /Applications/MAMP/htdocs/apeppers/romeo2/lib/Cake/Console/Command/Task/ViewTask.php on line 468
Fatal Error Error: Call to undefined method File::schema() in [/Applications/MAMP/htdocs/apeppers/romeo2/lib/Cake/Console/Command/Task/ViewTask.php, line 468]

Before that I have some error with my database connection which I solved using sudo ln -s in MAMP mysql bin to library mysql bin.

2
Looks like something is configured incorrectly. Try re-installing CakePHP and take care in noting the app path.Martin Bean
I already did! I even change the cake version but doesn't work!Cald
var_dump() whatever’s passed to dirname() on line 89 of /Applications/MAMP/htdocs/apeppers/romeo2/lib/Cake/Utility/File.php. That may point you in the direction of what’s wrong.Martin Bean
DId you create a model named File?AD7six
Yes I did.. I figured that out last night and my thoughts were "can't be something so stupid" and it was!Cald

2 Answers

1
votes

In CakePHP you can't bake a table named files for some reason this conflict with cake's File.php module.

0
votes

In case anybody else has the same problems I did, here's what I had to do to get the error to go away:

  1. Change my table name from "files" to something else (I used "available_files")
  2. Change all foreign keys in other tables from "file_id" to "available_file_id"
  3. Use "cake schema generate" to regenerate the schema

I also deleted all of the old files that had gotten generated, including in the app\Test directory. I don't know if this is necessary, but I wanted everything as clean as possible.