Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Issue #56: missing minimal configuration for Zend\Db #57

Closed

Conversation

DragonBe
Copy link
Contributor

@DragonBe DragonBe commented Sep 6, 2016

I added a few lines for people new to the framework to at least have a minimal db configuration to launch the ZF application without errors.

I added a few lines for people new to the framework to at least have a minimal db configuration to launch the ZF application without errors.
@weierophinney
Copy link
Member

I'm wondering if we need to fix zend-db, actually.

The culprit is that we auto-register the AdapterInterface service as a factory, which requires the db key in order to work. The question I have, though, is why this would trigger in the first place, unless there is code somewhere fetching the AdapterInterface service...

(The AdapterAbstractServiceFactory is smarter about this, and does some isset() checks; however, as an abstract factory, that's to be expected, as it needs to find configuration in order to report it can create the instance in the first place.)

I'll see if I can track down what might be using the adapter, so we can fix the root cause.

@weierophinney
Copy link
Member

@DragonBe I can't reproduce the issue when following the instructions in the tutorial.

I did the following:

$ composer create-project zendframework/skeleton-application test-zend-db

I answered all questions according to the tutorial at that point.

When done, I did the following:

$ cd test-zend-db
$ composer serve

and then visited http://localhost:8080/. The page came up as expected, and the built-in web server registered no errors in its error log.

I double-checked my PHP configuration as well: display_errors is enabled, and error_reporting is set to E_ALL.

Can you try again, perhaps in a vm or docker image, to see if the issue is present in a fresh install? Also, what version of the skeleton was retrieved when you ran it?

@weierophinney
Copy link
Member

Just as an experiment, I also threw in the -s dev flag when creating the project; no change.

@DragonBe
Copy link
Contributor Author

DragonBe commented Sep 6, 2016

Give me bit of time where I'll start a clean start of the project.

I had it already a couple of times when migrating old ZF1 apps into a clean structured ZF3 app, but forgot to mention it. Now building our Continuous Delivery dashboard from scratch I decided to report it.

I'll get back to this.

@DragonBe
Copy link
Contributor Author

DragonBe commented Sep 6, 2016

@weierophinney,

I've recorded a quick screencast where I can reproduce the issue.

Let me know if it clarifies things more for you.

@weierophinney
Copy link
Member

@DragonBe Figured it out: you didn't follow the tutorial directions, which is why I wasn't able to recreate it previously!

The issue is the installation of the developer toolbar. The Module class for that module checks to see if the zend-db AdapterInterface service is present in the container, and, if so, pulls it. Because zend-db registers the factory for that service by default, if zend-db is installed, then we observe an issue: retrieving the service raises an exception due to lack of configuration.

I'm at a quandary at how to address this. If you follow the tutorial exactly (and do not enable the toolbar), everything works as detailed. However, if you do add the toolbar and zend-db, but do not configure a database from the outset, you'll run into issues.

I have two ideas for how to resolve this:

  • In the skeleton, we could include default DB configuration using an in-memory sqlite database.
  • Alternately, we could do that in the zend-db ConfigProvider and Module classes.

Thoughts on which approach you think makes most sense?

weierophinney added a commit to weierophinney/zend-db that referenced this pull request Sep 7, 2016
Defines a default adapter using an in-memory SQLite database. This is
done to prevent failurs when adding zend-db to an application that retrieves
the adapter via the container:

```php
$container->get(\Zend\Db\Adapter\AdapterInterface::class)
```

This was observed when adding ZendDeveloperTools to a ZF3 application
while also installing zend-db, but without first configuring zend-db.

Reported at: zendframework/tutorials#57
@weierophinney
Copy link
Member

@DragonBe I've created a patch against zend-db that will address this; please review zendframework/zend-db#164.

@DragonBe
Copy link
Contributor Author

DragonBe commented Sep 7, 2016

Sorry @weierophinney,

I've been busy all day doing other stuff (and now in the car driving from traffic jam to the next one).

If time permits I can review it tonight, but I think tomorrow is a safer bet.

Is the installation of the development toolbar separate from the other installations? Guess I missed it and hit "y" on all questions. Sorry for creating confusion.

Today I hit the same issue for another project, but also for this project the toolbar is enabled.

Thanks for checking though, now I owe you dinner 😃

On 07 Sep 2016, at 21:35, weierophinney [email protected] wrote:

@DragonBe I've created a patch against zend-db that will address this; please review zendframework/zend-db#164.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

@samsonasik
Copy link
Contributor

if it related with ZendDeveloperTools, should be fixed by zendframework/zend-developer-tools#218

@froschdesign
Copy link
Member

I will close this PR, because:

  • ZendDeveloperTools was the problem
  • adding database configuration at this point makes no sense, when later in the tutorial everything is different

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants