Cakephp 3.9 Application Class not found - cakephp-3.0

After updating from Cake 3.8 to latest 3.9 my site no longer loads:
( ! ) Fatal error: Uncaught Error: Class 'Application' not found in webroot\index.php on line 31
( ! ) Error: Class 'Application' not found in webroot\index.php on line 31.
My src/App;lication.php;
require dirname(__DIR__) . '/vendor/autoload.php';
use App\Application;
use Cake\Http\Server;
// Bind your application to the server.
$server = new Server(new Application(dirname(__DIR__) . '/config'));
// Run the request/response through the application
// and emit the response.
$server->emit($server->run());
Line 31 is:
new Server(new Application(dirname(DIR) . '/config'));
I have tried to debug this and the error comes from the 'new Application'. As far as I can see the way that the Application class is referenced is as it is done elsewhere, in cake.php for example.
I have checked the book for version 3.9 release notes. It seems there are a few other posts on SO reporting similar issues with earlier 3.x versions but none with a proper answer.
Any suggestions as I am totally at a loss.

I created a new project via composer-update and installed all packages as required. I then copied the vendor folder of new project into the old broken project to fix. Problem was in the vendor folder it seems - what the issue was remains a mystery and I am still not clear how the problem was introduced.

The composer.json file needs this section
"autoload": {
"psr-4": {
"App\\": "src/"
}
to tell Composer to load the App namespace (along with others) into vendor/composer/autoload_psr4.php.
Then run composer dump-autoload or composer update.
I had the same problem upgrading from 2.10.24 to 3.9.

Related

Composer init (new project) Aborted with Symfony RuntimeException

In a new folder completely empty :
composer init
i have :
Welcome to the Composer config generator
This command will guide you through creating your composer.json config.
Package name (<vendor>/<name>) [slordef/test-composer]:
[Symfony\Component\Console\Exception\RuntimeException]
Aborted
init [--name NAME] [--description DESCRIPTION] [--author AUTHOR] [--type [TYPE]] [--homepage HOMEPAGE] [--require REQUIRE] [--require-dev REQUIRE-DEV] [-s|--stability STABILITY] [-l|--license LICENSE] [--repository REPOSITORY]
Composer is up to date...
Dont know how it append
This is probably a problem with PHP version 7.4, had to switch to version 7.3 to make it work
by running :
composer init -vvv
get :
Exception trace:
() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/console/Helper/QuestionHelper.php:148
Symfony\Component\Console\Helper\QuestionHelper->doAsk() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/console/Helper/QuestionHelper.php:75
Symfony\Component\Console\Helper\QuestionHelper->Symfony\Component\Console\Helper{closure}() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/console/Helper/QuestionHelper.php:404
Symfony\Component\Console\Helper\QuestionHelper->validateAttempts() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/console/Helper/QuestionHelper.php:78
Symfony\Component\Console\Helper\QuestionHelper->ask() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/IO/ConsoleIO.php:291
Composer\IO\ConsoleIO->askAndValidate() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Command/InitCommand.php:240
Composer\Command\InitCommand->interact() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/console/Command/Command.php:230
Symfony\Component\Console\Command\Command->run() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/console/Application.php:835
Symfony\Component\Console\Application->doRunCommand() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/console/Application.php:185
Symfony\Component\Console\Application->doRun() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Console/Application.php:267
Composer\Console\Application->doRun() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/console/Application.php:117
Symfony\Component\Console\Application->run() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Console/Application.php:106
Composer\Console\Application->run() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/bin/composer:61
require() at C:\ProgramData\ComposerSetup\bin\composer.phar:24
i had the same bug, but I after all I realized that it happens in the last version of php. Example: I am now using PHP 7.4 but when I switched to PHP 7.3.12 the bug was solved! So I could dare saying that for that specific bug the first thing to check is the version of PHP you're using whether is it stable of not..
Uninstall and reinstall Composer. Note that when installing, set php version 7.0. * To environment variables. So your problem will be solved

Can not generate service, versioning conflict. What could I broke?

I use feathers for some months now and I already created and used several services. The app is generated with feather/cli command: 'feathers generate app'.
Today I tried to generate a new service with the usual command:
feathers generate service
only to get the error:
× This version of the generator will only work with Feathers Buzzard (v3) and up. Please runfeathers upgradefirst.
Fine. Run the upgrade. Got new error:
throw new Error('It looks like#feathersjs/feathersis already a dependency. I can not run the upgrade again.');
^
checked the version: is 3.9.0
Uninstalled/re-installed feathers/cli
Nothing works. Not sure what I broke as I did not (remember to) upgrade anything since a couple of days ago when I created the last service. Feathers was not updated in the last 4 months.
I tried googling my error but it seems like nobody else has this problem so it has to be something I've done.
Any suggestions?
LE: I have in package.json dependencies:
"#feathersjs/errors": "^3.3.6",
"#feathersjs/express": "^1.3.1",
"#feathersjs/feathers": "^3.3.1",
"#feathersjs/socketio": "^3.2.9",
"feathers-knex": "^5.0.7",
"feathers-memory": "^3.0.2",
"feathers-rest": "^1.8.1",
"feathers": "^2.2.4",```
This error will be shown if you still have the feathers module in your dependencies in your package.json. If #feathersjs/feathers is already included as well you can just remove the feathers dependency (after making sure it is not used anywhere else in your application which it shouldn't).

The "GenerateDepsFile" task failed unexpectedly

I tried to compile my new application in MonoDevelop and I got this error:
/usr/share/dotnet/sdk/2.2.203/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(5,5): Error MSB4018: The "GenerateDepsFile" task failed unexpectedly.
System.TypeLoadException: Could not load type of field 'Microsoft.NET.Build.Tasks.DependencyContextBuilder:_filteredPackages'
(12) due to: Could not resolve type with token 01000027 from typeref
(expected class 'NuGet.Packaging.Core.PackageIdentity' in assembly
'NuGet.Packaging, Version=5.0.0.6, Culture=neutral,
PublicKeyToken=31bf3856ad364e35') assembly:NuGet.Packaging,
Version=5.0.0.6, Culture=neutral, PublicKeyToken=31bf3856ad364e35
type:NuGet.Packaging.Core.PackageIdentity member:(null)
at Microsoft.NET.Build.Tasks.TaskBase.Execute () [0x00000] in :0
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute
() [0x00029] in <58f0218f988743a48dd7c84cbe933f4e>:0
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask (Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost,
Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext,
Microsoft.Build.BackEnd.TaskHost taskHost,
Microsoft.Build.BackEnd.ItemBucket bucket,
Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask) [0x001f6]
in <58f0218f988743a48dd7c84cbe933f4e>:0 (MSB4018) (passcracker)
I cannot compile any application. Please help.
I had the same problem using .Net Standard 2.1, and I solved it for myself by cleaning the solution and then rebuilding it.
Just moved my projects to a new machine (copying, not pulling from GIT) and started getting this. Deleting the bin and obj folders in each project solved this issue.
Your combination of Mono MSBuild and .NET Core SDK is incompatible because they use different versions of the internal NuGet library. To resolve this problem, you can:
Downgrade .NET Core SDK to 2.1.5xx or 2.2.1xx (for example, 2.1.505 or 2.2.108)
Upgrade Mono to 6.0
You can find a detailed explanation of this problem and possible solutions here: https://rider-support.jetbrains.com/hc/en-us/articles/360004180039
This appears to be a known issue.
The only fix at this stage seems to be to downgrade to .NET Core v2.2.105.
To downgrade:
Uninstall the latest .NET Core version (v2.2.2+).
Download and install v2.2.105.
Run the following CMD in the *.sln folder. This will delete all your OBJ and BIN folders automatically. And your issue will be solved.
FOR /d /r . %%d in (bin,obj) DO ( IF EXIST "%%d" ( ECHO %%d | FIND /I "\node_modules\" > Nul && ( ECHO.Skipping: %%d ) || ( ECHO.Deleting: %%d rd /s/q "%%d" )))
I had the same problem in migration from .Net Framework 4.5 to .NET 6.0 (with the 70 project).
All of the above answers are correct, but they were not enough for my problem.
I use this answer:
Deleting the bin and obj and .vs folders then Clean Solution and
Rebuild Solution
it's working in Build Mode, not Rebuild. And the problem remained.
I update the Version of SDK , but not enough and I have the problem.
I realized this:
duplicate property (or variables) with the same name (or similar Name) in derived classes.
It was a good solution and a few problems were solved.
finally (after the 3 days), The biggest problem I noticed was that I had Loop References.
I fixed The Loop References in projects and the error is solved.
Change the name of the file. For instance, Add prefix _ or #; so, it cannot be used.
Restart Visual Studio, then try to build. If still problem is there, needs to restart the machine.
I had this error happen and the slove for me was correcting the Package version number in .csproj file .
<Version>2.0.7.</Version> <!--casued the error-->
<Version>2.0.7</Version> <!--this fixed the error-->
Removing the trailing '.' fixed this for me.
I had .net standard project built on .net standard 2.0. Yesterday I updated my Visual Studio 2019 to 16.3.0 to leverage .Net Core 3.0. But all of sudden build of project targeting on standard 2.0 started throwing "GenerateDepsFile" task failed unexpectedly error.
I was able to resolve this issue by changing the target framework to 2.1.
If you have <DelaySign>false</DelaySign> in your .csproj file remove it to solve this Problem.
in vs code i got this error, after trying some solution from forms, i found solution in deleting bin and obj foldersfrom project and build again.
this solved my problem.
vs code version: 1.53.1
dotnet version : 5
I had it after updating vs 2019 community,
Delete bin & obj folders,
then clean & build the solution.
I had this error and after reading comments, I was able to resolve by combining comments - First deleted bin folder, obj folder, executed clean command, deleted enter image description here and then rebuilded.

In RouteRegistrar.php line 75: Attribute [Groupe] does not exist

when i usephp artisan serveto run my project it show me on error like this:
-->In RouteRegistrar.php line 75:
-->Attribute [Groupe] does not exist.
I had the same issue and bumped into your question via the Google-sphere.
Running composer install did the trick for me. I believe (at least in my case) that this error is the result of mismatched Laravel versioning vis-a-vis the routing code (I had the later version of Laravel specified in my composer.json but was working on an environment where I hadn't yet updated my composer packages).

3rd party Framework Library not loaded: 'Image not found'

I am upgrading a framework to latest version. Earlier integration (>2 years old) had framework directly copied in the project; now getting cocoapod (0.39.0) to get framework integrated with project using xcode (7.2.1) and objective-c project.
Upon run, it generates following error:
dyld: Library not loaded: #rpath/name.framework/name
Referenced from:
/Users/xyz_xyz/Library/Developer/CoreSimulator/Devices/xxxxxxx/data/Containers/Bundle/Application/xxxxxxx/appname.app/appname
Reason: image not found
"Pod" xcode-project has correct reference and framework is present in corresponding folder
Found that nameFramework isn't linked (added) in any of the build phases. I am new to using cocoapods and not sure what changes would be necessary in Xcode build settings to make transition from directly-embedded framework to cocoapods based integration.
how to get past "dyld: Library not loaded" error?
What phase should I use to reference name.Framework during build as it's not getting generated?
How to copy bundle resources from Pod to project? Dragging-n-drop Pods/name/Resources/name.bundle prompts "copy item if needed" dialog. <- I don't think I need to do this when using cocoapods.
[update] Integration using cocoapods works fine when a sample or new project is used. It's something in the current project settings that's causing the issue.
Podfile:
platform :ios, '8.0'
# use_framework for swift based pod integration. requires cocoapod 0.39.0
#use_frameworks!
pod 'GTMOAuth2'
pod 'Typhoon'
pod 'Alamofire'
# Issue with name
pod 'name', podspec:'https://customers.pspdfkit.com/cocoapods/.../latest.podspec'
target :ABC do
pod '...', '~>1'
end
target :XYZ do
pod '...', :path => 'submodules/...'
end
[Update]
- Upgraded to CocoaPods 1.0.1 & modified the Podfile to uncomment use_frameworks!, and make other changes that are required for 0.39.0 to 1.0.1 migration. Here is the updated Podfile.
platform :ios, '8.0'
# use_framework is required for dynamic links (swift) based pod integration.
use_frameworks!
target 'XYZ' do
pod 'GTMOAuth2'
pod 'Alamofire'
pod 'name', podspec:'https://customers.name.com/cocoapods/.../latest.podspec'
target :XYZ-A do
pod 'XYZ-iOS-SDK', :path => 'submodules/xyz-ios-sdk'
end
end
Fixed errors such as following by adding $(inherited) flag (where applicable)
[!] The XYZ-v2 [Release] target overrides the OTHER_LDFLAGS build setting defined in ...
Progress after above changes, Pods/Target Supported Files/XYZ-v2/ has Pods-XYZ-v2-frameworks.sh and resources.sh; earlier frameworks.sh was missing. Following is partial content of the framworks.sh, and it does contain copy instructions.
if [[ "$CONFIGURATION" == "Debug" ]]; then
install_framework "$BUILT_PRODUCTS_DIR/GTMOAuth2/GTMOAuth2.framework"
install_framework "$BUILT_PRODUCTS_DIR/GTMSessionFetcher/GTMSessionFetcher.framework"
install_framework "$BUILT_PRODUCTS_DIR/GoogleAPIClient/GoogleAPIClient.framework"
install_framework "$BUILT_PRODUCTS_DIR/Mantle/Mantle.framework"
install_framework "${PODS_ROOT}/PSPDFKit/PSPDFKit.framework"
install_framework "$BUILT_PRODUCTS_DIR/SSKeychain/SSKeychain.framework"
fi
// and for "Release" & "Distribution" as well..
Now I am trying to resolve compile errors upon build, which are related to static vs dynamic library includes.
/path../Pods/SSKeychain/Sources/SSKeychain.h:65:1: Duplicate interface definition for class ‘SSKeychain'
[Updated] Posted a new question: CocoaPods 1.0.1 Redefinition of 'XYZ', Redefinition of enumerator 'ABC', Duplicate interface definition for 'MNO'
Related:
OS X Framework Library not loaded: 'Image not found'
Seems relevant: https://github.com/CocoaPods/CocoaPods/issues/4772
Try using use_frameworks! (it's currently commented out). PSPDFKit is a dynamic framework, so you need to enable this option.
Also try it with the newest Xcode and CocoaPods >= 1.0.0. Older versions might not work correctly.
You can find more information about PSPDFKit integration via CocoaPods here: https://pspdfkit.com/guides/ios/current/getting-started/using-cocoapods
If all of this doesn't help you can reach the PSPDFKit developers directly at https://pspdfkit.com/support/request
same issue on dyld: Library not loaded: #rpath/TwilioAccessManager.framework/TwilioAccessManager
Reason: image not found
I had the same problem, this fixed it for me.I Changed Framework status required to optional .