Laravel 5 - Custom Package "Class Not Found" When Pushed to Heroku - php

I'm having a bit of trouble getting a custom package to work when deploying my Laravel app to Heroku. It works fine locally, but when pushed I get the following error:
In ProviderRepository.php line 208: Class 'totalWebConnections\simpleBlog\simpleBlogServiceProvider' not found
It looks like the server is correctly loading the package from my composer file, just above the error in the log:
Installing totalwebconnections/simple-blog (1.0.0)
In my composer.json
"require": {
"php": ">=5.6.4",
"laravel/framework": "5.4.*",
"laravel/tinker": "~1.0",
"totalwebconnections/simple-blog": "1.0.0"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~5.0"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/",
"totalWebConnections\\simpleBlog\\": "vendor/totalWebConnections/simple-blog/src/"
}
},
And then in my app.php
totalWebConnections\simpleBlog\simpleBlogServiceProvider::class,
I'm not sure what the issue is?

I think you should double check your namespaces and case of file names - when you deploy on Windows for example it doesn't care whether it's simpleBlog or SimpleBog but when deployed to Linux server it won't work if it's not 100% same as it should be.

Related

CakePHP Migration 3.9 to 4.2 Undefined Method Cake\Core\Plugin::load()

I'm migrating CakePHP from version 3.9 to 4.2 and I'm seeing the error:
Exception: Call to undefined method Cake\Core\Plugin::load()
on the following line in config/bootstrap_cli.php
Plugin::load('Bake');
It seems either Core or Plugin is not being imported correctly. Earlier in config/bootstrap_cli.php I have:
use Cake\Core\Plugin;
Perhaps it isn't being installed correctly? My composer.json contains the following:
"require": {
"php": ">=5.4.16",
"cakephp/cakephp": "^4.0",
"mobiledetect/mobiledetectlib": "2.*",
"cakephp/migrations": "~3.0",
"cakephp/plugin-installer": "^1.0",
"phpunit/phpunit": "^8.0",
"cakephp/bake": "^2.0",
"cakephp/core": "^4.0"
},
"autoload": {
"psr-4": {
"App\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"App\\Test\\": "tests",
"Cake\\Test\\": "./vendor/cakephp/cakephp/tests"
}
},
"scripts": {
"post-install-cmd": "App\\Console\\Installer::postInstall",
"post-autoload-dump": "Cake\\Composer\\Installer\\PluginInstaller::postAutoloadDump"
},
Since v4 of CakePHP, there is no such method. You should check for deprecation messages before upgrading: the code from the last release of v3.9 holds an important message for your problem:
#deprecated 3.7.0 This method will be removed in 4.0.0. Use Application::addPlugin() instead.

Laravel 5.2 | Issue with bootstrap/cache/compiled.php

Good afternoon,
I had a time with a problem running composer update in my production repository. Only in production, in DEV and PRE does not happen to me, everyone has the same configuration and at the end pull almost the same repository and share composer.json
I'm using "laravel / framework": "5.2. *", With PHP 7.0
The problem I have is that when launching composer update, I generate this file, bootstrap / cache / compiled.php but only in PROD, in neither of the other versions generates it, nor in local. With this file loaded the application gives an error 500 and reports this failure:
PHP Fatal error: Can not declare class Illuminate \ Support \ ServiceProvider, because the name is already in use in /var/www/vhosts/proyecto/bootstrap/cache/compiled.php on line 5267
If I delete this file by hand the application works again, but this should not happen, in addition, the applications that I try to install with composer, since I have this bug, do not work, I declare them in config / app.php and check that this The folder in vendor and everything is correct, but it gives another 500 so the reason why it does not erase or generate bootstrap / cache / compiled.php makes the installations do not end up being correct.
Please, could you help me, I do not know what else to look or do ....
This is my composer file:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.*",
"twbs/bootstrap": "^3.3",
"laravelcollective/html": "5.2.*",
"joshcam/mysqli-database-class": "dev-master",
"opentok/opentok": "2.3.x",
"intervention/image": "^2.3",
"hisorange/browser-detect": "2.*",
"ignited/laravel-omnipay": "2.*",
"omnipay/omnipay": "*",
"skecskes/calendar": "0.2.*",
"webpatser/laravel-uuid": "^2.0",
"barryvdh/laravel-debugbar": "^2.2",
"maatwebsite/excel": "~2.1.0",
"paypal/rest-api-sdk-php": "*",
"laracasts/flash": "^2.0",
"doctrine/dbal": "^2.5",
"laravel/cashier": "~6.0",
"barryvdh/laravel-dompdf": "0.7.*",
"dompdf/dompdf": "^0.7",
"ovh/ovh": "^2.0",
"docusign/esign-client": "^2.0",
"sentry/sentry": "^1.6",
"sentry/sentry-laravel": "^0.7.0"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"symfony/css-selector": "2.8.*|3.0.*",
"symfony/dom-crawler": "2.8.*|3.0.*"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist"
}
Thank you very much,
greetings
Update 2017/06/15 08:00 CEST
Remove, one by one the third party package from the require/requir_dev section and retry composer update
Mostly, third party packages cause this error. You can do the following things:
Run php artisan clear-compiled and retry composer update
Remove the generated service provider from compiled.php and retry composer update
Make a fresh installation
You're using PHP 7.0. It's not forbidden (I recommend) to use a newer version of Laravel!

Adding league s3 filesystem breaks auto loading

After adding the Leauge S3 filesystem adaptor I receive the following auto loading error on my EBS system.
composer.json
"require": {
"php": ">=5.5.0",
"slim/slim": "2.3.2",
"slim/extras": "dev-develop",
"twig/twig": "1.*",
"directus/migrations": "dev-master",
"directus/permissions": "0.9.*#dev",
"directus/database": "~0.1.3",
"league/flysystem": "^1.0",
"league/flysystem-aws-s3-v3": "^1.0",
"swiftmailer/swiftmailer": "^5.4" },
Error:
Failed opening required
'/var/app/current/vendor/composer/../guzzlehttp/psr7/src/functions_include.php'
(include_path='/var/app/current/vendor/phpunit/php-token-stream:/var/app/current/vendor/phpunit/phpunit-mock-objects:/var/app/current/vendor/phpunit/php-code-coverage:/var/app/current/vendor/phpunit/phpunit:/var/app/current/vendor/symfony/yaml:.:/usr/share/pear7:/usr/share/php7')
in /var/app/current/vendor/composer/autoload_real.php on line 70
try updating composer with
>composer self-update
You can also clear the cache of composer launching the command:
>composer clear-cache
Hope this help

Heroku rejects push because it cannot clear the cache Symfony3

Working all day to deploy my application to heroku, but every time it throws out an error. And i am all out of clues, and have a very angry customer.
When i try to add my project to heroku with the command git push heroku master every thing is fine till the cache needs to be cleared.
Updating the "app/config/parameters.yml" file
remote: > Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap
remote: > Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache
remote: Could not open input file: app/console
remote: Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the symfony-scripts event terminated with an exception
remote:
remote:
remote: [RuntimeException]
remote: An error occurred when executing the "'cache:clear --no-warmup'" command:
remote: Could not open input file: app/console
remote: .
You would think, it's the same as this git issue
Also a know problem, that i am using a wrong type of mapping.
But i think it's fine.
I updated my composer and cleared the cache of my composer
And when i clear the cache with php bin/console cache:clear everything is fine!
I followed this tutorial
And got some side information from the symfony site.
Also found this stack - with the explanation what is going on, but this is still not solving my problem.
Maybe it's somewhere in my composer file, or my git ignore.
But honestely, i have no idea anymore.
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-4": { "": "src/" },
"classmap": [ "app/AppKernel.php", "app/AppCache.php" ]
},
"autoload-dev": {
"psr-4": { "Tests\\": "tests/" }
},
"require": {
"php": ">=5.5.9",
"symfony/symfony": "3.1.*",
"doctrine/orm": "^2.5",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/doctrine-cache-bundle": "^1.2",
"symfony/swiftmailer-bundle": "^2.3",
"symfony/monolog-bundle": "^2.8",
"symfony/polyfill-apcu": "^1.0",
"sensio/distribution-bundle": "^5.0",
"sensio/framework-extra-bundle": "^3.0.2",
"incenteev/composer-parameter-handler": "^2.0",
"friendsofsymfony/user-bundle": "~2.0#dev",
"symfony/assetic-bundle": "^2.8",
"stfalcon/tinymce-bundle": "2.0",
"egeloen/ckeditor-bundle": "^4.0",
"whiteoctober/tcpdf-bundle": "^1.0",
"gregwar/captcha-bundle": "^2.0"
},
"require-dev": {
"sensio/generator-bundle": "^3.0",
"symfony/phpunit-bridge": "^3.0"
},
"scripts": {
"symfony-scripts": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
],
"post-install-cmd": [
"#symfony-scripts"
],
"post-update-cmd": [
"#symfony-scripts"
],
"compile": [
"rm web/app_dev.php",
"bin/console cache:clear",
"bin/console assetic:dump"
]
},
"config": {
"platform": {
"php": "5.5.9"
}
},
"extra": {
"symfony-app-dir": "app",
"symfony-bin-dir": "bin",
"symfony-var-dir": "var",
"symfony-web-dir": "web",
"symfony-tests-dir": "tests",
"symfony-assets-install": "relative",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": {
"dev-master": "3.1-dev"
}
}
}
The solution that worked for me. New Symfony 3 installation: Could not open input file: app/console in composer install
EXPLANATION:
That's what I guess. When you push your code to Heroku, the platform compiles your project files on the /tmp dir. What happens if you don't have a var dir when Heroku compiles your code? What happens is that Symfony creates a new one:
vendor/sensio/distribution-bundle/Composer/ScriptHandler.php:462
protected static function useNewDirectoryStructure(array $options)
{
return isset($options['symfony-var-dir']) && is_dir($options['symfony-var-dir']);
}
Then when Heroku moves your new code to the /appdir, the Symfony configuration still points to the old placement /tmp, but files placed at /tmp are now deleted!
You upgraded a Symfony 2 app to 3.
But it is not sufficient to change the requirements in composer.json.
The structure changed, so you need to first create a new fresh app with Symfony 3 and then move the old Symfony 2 app to the fresh Symfony 3 one, bundle by bundle, composer requirement by composer requirement.
This way you'll be sure your app will work well on version 3.
If you try to simply upgrade the requirements from a Symfony 2 app, then you'll create a lot of bugs, as the scripts changed, the structure changed, the requirements changed...
The only safe way is to start a new Symfony 3 project and then port the old Symfony 2 into it.
I took a look at your github repository. Seems like it's in the Symfony3 format, so I'm not certain what is going on. I want to try something, but I'm not sure if it will work.
Try editing your composer.json file manually to add the bin directory:
"config": {
"bin-dir": "bin",
"platform": {
"php": "5.5.9"
}
},
Then see if that fixes the problem.
EDIT #2
Now revert those changes and try this:
"extra": {
"symfony-app-dir": "bin",
"symfony-bin-dir": "bin",
"symfony-var-dir": "var",
In other words change the app directory to "bin".

How to work on a fork in GitHub

I would like to update a repo in GitHub to make it compatible with ZF3, I have forked the repository to my account and made some updates.
This is my fork: https://github.com/chateaux/zf-oauth2-doctrine
Now to include this in my code base I am using Composer:
{
"name": "My Project",
"description": "",
"license": "PRIVATE - ",
"keywords": [
""
],
"homepage": "",
"repositories": [
{
"type": "vcs",
"url": "https://github.com/chateaux/zf-oauth2-doctrine"
}
],
"require": {
"php": ">=5.4",
"zendframework/zendframework": "^2.4",
"doctrine/doctrine-orm-module": "~0.8",
"doctrine/orm": "^2.4",
"gedmo/doctrine-extensions": "^2.4",
"zf-commons/zfc-rbac":"^2.5",
"rwoverdijk/assetmanager": "^1.4",
"zfcampus/zf-apigility": "^1.0",
"zfr/zfr-cors": "^1.2",
"hounddog/doctrine-data-fixture-module": "^0.0.4",
"zfcampus/zf-oauth2-client": "dev-master",
"api-skeletons/zf-oauth2-doctrine": "dev-master",
"api-skeletons/zf-oauth2-doctrine-console": "^1.1",
"chateaux/toolbox" : "dev-master"
},
"require-dev": {
"zfcampus/zf-apigility-admin": "~1.0",
"zfcampus/zf-development-mode": "~2.0",
"zendframework/zend-developer-tools": "dev-master"
}
}
However when I run a composer update, it appears to be pulling from a cache so I am not getting my updated code base:
$ php composer.phar update
You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
Warning: This development build of composer is over 60 days old. It is recommended to update it by running "composer.phar self-update" to get the latest version.
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing zfcampus/zf-oauth2-doctrine (1.0.3)
Loading from cache
What am I doing wrong?
You should add your custom fork of the repository to the repositories array in your composer.json file and add a type field git and then point to the branch you want to use with dev-[branchname] (for example patch-4 becomes dev-patch4):
{
"name": "My ZF2 application",
"repositories": [
{
"type": "git",
"url": "https://github.com/chateaux/zf-oauth2-doctrine.git"
},
],
"require": {
...
"zfcampus/zf-oauth2-doctrine": "dev-patch-4",
...
}
}
Make sure that patch-4 is an existing branch in your custom repository.
You can find more information on this solution on the first hit from Google.

Categories