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.
Leave a Comment