How to fix Cannot redeclare Aws\constantly fatal error

Cannot redeclare Aws constantly

If you are using any amazon aws library and you are experiencing a fatal error that reads “Cannot redeclare Awsconstantly() (previously declared in“, then it means that the function is being declared twice. This normally happens when you include a file in your scripts using include or require.

Solution

To fix the error, all that you need to do is to make sure that you use the include_once() or require_once() function. This will prevent the function causing the error from being included in your script twice.

We were facing the same problem while developing a PHP application that sends emails using Amazon SES and AWS SDK for PHP and the solution above fixed the problem.

If you do not fix the problem, nothing will happen but your error log file will continue to grow in size as the error will be generated each time the script that uses AWS SDK is executed or accessed.

Last updated on

by

Published In

Leave a Comment

Your email address will not be published. Required fields are marked *

Editors Pick

css.php