Lumen -> Error on line 54 - require(): Failed opening required - php

I install a fresh copy of Lumen as Heroku app. Also I implemented the packange Dingo into it: https://github.com/dingo/api/ but when I try to load everything server return me this error:
2016-02-14T11:07:45.657820+00:00 app[web.1]: [14-Feb-2016 11:07:45 UTC] PHP Warning: require(/app/vendor/dingo/api/src/helpers.php): failed to open stream: No such file or directory in /app/vendor/composer/autoload_real.php on line 54
2016-02-14T11:07:45.657998+00:00 app[web.1]: [14-Feb-2016 11:07:45 UTC] PHP Fatal error: require(): Failed opening required '/app/vendor/dingo/api/src/helpers.php' (include_path='.:/app/.heroku/php/lib
/php') in /app/vendor/composer/autoload_real.php on line 54
I tried to remove vendor folder, etc and reinstall it but result is the same
EDIT: My composer.json is:
{
"name": "laravel/lumen",
"description": "The Laravel Lumen Framework.",
"keywords": ["framework", "laravel", "lumen"],
"license": "MIT",
"type": "project",
"minimum-stability": "dev",
"require": {
"php": ">=5.5.9",
"laravel/lumen-framework": "5.2.*",
"vlucas/phpdotenv": "~2.2",
"dingo/api": "1.0.x#dev"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"phpunit/phpunit": "~4.0",
"dingo/api": "1.0.x#dev"
},
"autoload": {
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/",
"database/"
]
}
}
EDIT 2: I tried now in my local machine and Lumen with Dingo works correctly so it's something with Heroku sigh. How to see Lumen Logs in Heroku Logs?

I think you missed to add configuration in your Heroku App. To make your Heroku app fetching all the composer requirements, you may run this on your root of Lumen App:
heroku config:add BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-php
Make a change again, then push your changes to heroku repository, eg:
git push heroku master
Edit
To make this works, I have my own way to deploy Lumen App to Heroku.
lumen new my-app
cd my-app
# Here you can change your composer.json dependencies
composer require dingo/api
Make your procfile
vim Procfile
# Content of Procfile
web: vendor/bin/heroku-php-apache2 public
Initialize repo
git init
git add -A .
git commit -m "[INIT] Initial commit."
Create Heroku app:
heroku create
heroku config:add BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-php
git push heroku master
Visit your heroku app.

Related

cant install cakephp 4 again

I have wamp64, php 7.4 and using composer I ran this from the console
composer create-project --prefer-dist "cakephp/app:^4.0" myapp
and
composer create-project --prefer-dist cakephp/app:~4.0 my_app_name
The installation cut out towards the end with this error
Script App\Console\Installer::postInstall handing the post create project cmd event terminated with an exception
[Symfony\Component\Console\Exception\RunTimeException\ Aborted
and some Symfony runtime exception when you get to the set folder permission y/n
It created this JSON file
{
"name": "cakephp/app",
"description": "CakePHP skeleton app",
"homepage": "https://cakephp.org",
"type": "project",
"license": "MIT",
"require": {
"php": ">=7.2",
"cakephp/cakephp": "~4.2.0",
"cakephp/migrations": "^3.0",
"cakephp/plugin-installer": "^1.3",
"mobiledetect/mobiledetectlib": "^2.8"
},
"require-dev": {
"cakephp/bake": "^2.3",
"cakephp/cakephp-codesniffer": "~4.2.0",
"cakephp/debug_kit": "^4.4",
"josegonzalez/dotenv": "^3.2",
"phpunit/phpunit": "~8.5.0 || ^9.3",
"psy/psysh": "#stable"
},
"suggest": {
"markstory/asset_compress": "An asset compression plugin which provides file concatenation and a flexible filter system for preprocessing and minification.",
"dereuromark/cakephp-ide-helper": "After baking your code, this keeps your annotations in sync with the code evolving from there on for maximum IDE and PHPStan/Psalm compatibility.",
"phpstan/phpstan": "PHPStan focuses on finding errors in your code without actually running it. It catches whole classes of bugs even before you write tests for the code."
},
"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-create-project-cmd": "App\\Console\\Installer::postInstall",
"check": [
"#test",
"#cs-check"
],
"cs-check": "phpcs --colors -p src/ tests/",
"cs-fix": "phpcbf --colors -p src/ tests/",
"stan": "phpstan analyse",
"test": "phpunit --colors=always"
},
"prefer-stable": true,
"config": {
"sort-packages": true
}
}
How to Fix Cakephp 4 Composer Install Error
(i didnt understand the solution to this)
Cakephp 4 Windows Installation Issues
It should be possible to get it to work. What Windows version do you use? Pro or Home? Which distribution? 2010?
Please make sure to navigate to the WAMP install folder and then specifically the www folder.
The command I use is this;
composer create-project --prefer-dist cakephp/app:~4.0 cake
It worked for me.
Alternatively, download Cakephp version 4.0, place the contents in the www folder, and configure it manually through the file /config/app.php. If you want, we can look at it together. There are not many people around me that can or want to work on Cakephp, so it'd be a pleasure. :)

Can't require local package with composer

I'm currently working on a Composer package and now I want to test how it would integrate in my current application without pushing it to a remote.
So I stumbled upon this blog post which explains how to do that. However, that didn't work. I'm getting the message
Your requirements could not be resolved to an installable set of packages.
Problem 1 - The requested package tzfrs/x-bundle could not be found in any version, there may be a typo in the package name.
My directory structure looks like this
dev
Project
composer.json
Package
composer.json
The composer.json of my package looks like this
{
"name": "tzfrs/x-bundle",
"license": "proprietary",
"require": {
"php": "^7.0",
"psr/log": "~1.0"
},
"require-dev": {
"phpunit/phpunit": "~5.5"
},
"autoload": {
"psr-4": { "tzfrs\\XBundle\\": "" },
"exclude-from-classmap": [
"/Tests/"
]
}
}
And the one of my project looks like this (I'm leaving the symfony stuff and other packages/stuff out)
{
"repositories": [
{
"type": "git",
"url": "../Package",
}
],
"minimum-stability" : "beta",
"require": {
"tzfrs/x-bundle": "*"
}
}
So when doing composer update tzfrs/x-bundle I should get my new project right? However, I'm getting the message I posted above. What am I doing wrong here?
I already did git init in my package folder and also comitted all my changes. So I have a repo which is not empty already.

How to use the develop branch of Zend Framework 2 over composer?

In an Apigility driven application my composer.json is looking like this:
{
"name": "misc - myproject-api",
"description": "Skeleton Application for Apigility",
"require": {
"php": ">=5.3.23",
"zendframework/zendframework": ">=2.3.2,<3.0.0",
"zfcampus/zf-apigility": "~1.0",
"zfcampus/zf-apigility-documentation": "~1.0",
"zfcampus/zf-development-mode": "~2.0",
"zfcampus/zf-rest": "~1.0-dev",
"zf-commons/zfc-base": "dev-master",
"zendframework/zend-developer-tools": "dev-master",
"doctrine/doctrine-orm-module": "0.8.*"
},
"require-dev": {
"zendframework/zftool": "dev-master",
"zfcampus/zf-apigility-admin": "~1.0",
"zfcampus/zf-apigility-welcome": "~1.0",
"zfcampus/zf-deploy": "~1.0",
"zfr/zfr-cors": "~1.0",
"zend/zend-studio-development-mode": "~1.0"
},
"keywords": [
"api",
"apigility",
"framework",
"zf2"
],
"support": {
"email": "apigility-users#zend.com",
"irc": "irc://irc.freenode.net/apigility",
"source": "https://github.com/zfcampus/zf-apigility-skeleton",
"issues": "https://github.com/zfcampus/zf-apigility-skeleton/issues"
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev",
"dev-develop": "1.1-dev"
}
},
"config": {
"process-timeout": 5000
},
"type": "library",
"license": "BSD-3-Clause",
"homepage": "http://apigility.org/"
}
There is a ZF2 issue (that causes following error: Fatal error: Cannot use object of type Zend\Db\ResultSet\ResultSet as array). It has been fixed, but not merged to the master branch yet.
Since I need it working now, I tried to switch to the develop branch -- updated my composer.json
{
"name": "misc - myproject-api",
"description": "Skeleton Application for Apigility",
"require": {
"php": ">=5.3.23",
"zendframework/zendframework": "dev-develop as dev-master"
...
}
...
}
and executed a composer update:
$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Updating zendframework/zendframework (dev-master de98f63 => dev-develop be0b349)
Checking out be0b3496b73a61a255d05e945b75f6fdf0995c31
Writing lock file
Generating autoload files
Problem: I'm not observing any changes, the code seems still to be loaded from the ZF2 master branch (e.g. my local Zend\Paginator\Adapter\DbSelect has exactly the state of the according class in the master branch).
How to load the ZF2 develop branch?
UPDATE
I've triedthe the composer require direction value for the develop branch (2.4.*#dev) from the Packagist page of the Zend Framework. The result is the same as with dev-develop or dev-develop as dev-master -- the console shows the correct branch (or better the correct commit be0b349) downloading
$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Removing zendframework/zendframework (2.3.4)
- Installing zendframework/zendframework (dev-develop be0b349)
Cloning be0b3496b73a61a255d05e945b75f6fdf0995c31
Writing lock file
Generating autoload files
but after the updating, the code is still like in the master branch.
UPDATE
$ cd [project root directory]/vendor/zendframework/zendframework
$ git status
# On branch develop
nothing to commit (working directory clean)
That means, the branch is correct. And its also up-to-date, since the last commit , git log shows is be0b3496b73a61a255d05e945b75f6fdf0995c31 from 3d of February -- and that is actually the current HEAD revision.
So, the branch is correct, the revision is correct... Why is the code uot-of-date?
The "develop" branch has an alias to be version 2.4. You could require "2.4.*#dev" to get it.
If this breaks some of your dependencies, you could alias this with a 2.3 version.
"zendframework/zendframework": "dev-develop as 2.3.4.1"

Composer : how to add a dependency without network connection?

My profesionnal network block internet access. Some month ago I download the Silex framework from an archive (which contains composer.json file) and the composer.phar one's, then I transfer them on my desktop throught HDD.
My composer.json that I customized:
{
"name": "user/silex",
"require": {
"silex/silex": "1.2"
, "twig/twig": ">=1.8,<2.0-dev"
, "doctrine/dbal": "2.2.*"
, "symfony/security": "~2.3"
, "symfony/security": "~2.3"
},
"autoload": {
"psr-4": {
"Portal\\": "src/"
}
}
}
It works fine, my autoload customization too.
Today I want to add the monolog/monolog package, so I manually import it from an other computer.
I place it into my vendor folder, I add the following line to my composer.json file:
, "monolog/monolog": ">=1.0.0"
I run on the console:
php composer.phar dumpautoload
It outputs:
Generating autoload files
Then it stop without error, but the monolog namespace doesn't appear into my /vendor/composer/autoload_*.php files.
What did I miss?
Thanks to edmondscommerce's comment I found the solution:
I update my main composer.json file with an artifact respository (and I disable the packagist one):
{
"name": "user/silex",
"repositories": [
{
"type": "artifact",
"url": "artifact/"
}, {
"packagist": false
}
], "require": {
"silex/silex": "1.2"
, "twig/twig": ">=1.8,<2.0-dev"
, "monolog/monolog": "1.*"
, "doctrine/dbal": "2.2.*"
, "symfony/security": "~2.3"
},
"autoload": {
"psr-4": {
"Portal\\": "src/"
}
}
}
Then I put a folder called artifact according to the url put in the composer.json file.
I create into this folder a zip called monolog-monolog-1.8.zip with the library I want to add.
Then just launch a composer update command!
Be carefull, zip's root must contain a composer.json file, and this composer.json file must contain a version!
If you do not want to create a custom repository, you can also run composer install (or composer update) on a copy that is on a network-connected computer. Then you can copy over the newly added and extracted component into the vendor folder on the machine without internet access. Note that you also need to copy vendor/composer/installed.json to let composer know that the new package has been installed. Once you have copied all these files, you can run composer install on the machine without internet access and it will not try to install anything and dump autoload files.

doctrine:generate:entities and vendor bundles

I'm trying to organize my project with a base code and external bundles as a plugins for the base project.
I've already registered the bundles in packagist and the "composer.phar install" command works as expected. The autoloader also works as expected, so everything is OK but the "php console doctrine:generate:entities ACSACSPanelDynHostBundle" command don't work at all. It returns the next message:
[RuntimeException]
Can't find base path for "ACSACSPanelDynHostBundle" (path: "/var/www/acspanel/vendor/acs/paneldynhost", destination: "/var/www/acspanel/vendor/acs/paneldynhost").
I tryied to use psr-4 in composer.json to define the namespace but it don't works either.
I would like to know what is the proper way to use the console commands with my vendor bundles.
The code of my bundle composer.json is:
{
"name": "acs/paneldynhost",
"description": "Dynhost service creation for ACSPanel",
"keywords": ["dynamic domain","acspanel"],
"type": "
"autoload": {
"psr-4": { "ACS\\ACSPanelDynHostBundle\\": "" }
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"phpunit/phpunit": "3.7.*"
}
}

Categories