I use symfony3. Have the only bundle - AppBundle. I use yml for annotation. They live in AppBundle\Resources\config\doctrine. If I want a new entity - I create new .orm.yml file and then run php bin/console doctrine:generate:entities AppBundle. Everything works fine.
Once I needed another namespace for my entity. So I created a folder Filter in doctrine folder. And put a Category entity there. And then called a 'generate' command. I had an error No mapping file found named 'Category.orm.yml' for class 'AppBundle\Entity\Filter\Category'. Then removed Filter folder and recall the command. And everything worked fine. So the issue is in an additional folder. I tried to place Category just in doctrine folder but keep namespace in yml file (AppBundle\Entity\Filter\Category). That does not work.
So the question is: how to create an annotation for an antity with a parent namespace?
You can test it using the php bin/console doctrine:generate:entity command:
The Entity shortcut name: AppBundle:Filter/Category
This is how your project structure would be generated. No subdirectory in the doctrine directory, but instead the namespace in the YAML filename along:
src/
└── AppBundle/
├── Entity/
│ ├── Filter/
│ │ └── Category.php
│ └── SomeEntity.php
└── Resources/
└── config/
└── doctrine/
├── Filter.Category.orm.yml
└── SomeEntity.orm.yml
Related
Let's assume a config group foo and config files organized in the following directory structure:
conf
├── foo
│ ├── bar
│ │ ├── a.yaml
│ │ ├── b.yaml
│ │ ├── c.yaml
│ └── baz
│ ├── d.yaml
│ ├── e.yaml
│ └── f.yaml
Each of the yaml files sets the package to foo using # #package foo. When running the corresponding application, I can simply override foo by specifying something like foo=bar/a or foo=baz/f. Thereby, the sub-directories bar and baz indicate a certain category withing a larger set of possible configurations.
While this works fine for standard use in hydra, some more advanced features of hydra appear to be not compatible with this structure. For instance, I would like to use glob in conjunction with the directory structure like this foo=glob(bar/*) to sweep over all configs of a certain category. However, this does not appear to work as glob does not find any configs in this example. Also if I assign an invalid config to foo and hydra lists the available options, the list is empty.
This makes me wonder if structuring within a config group is a generally supported feature in hydra, and just some corner cases are not covered yet, or if I am using hydra wrong and directories should not be used for organizing configs in a group?
This is not recommended, but not explicitly prohibited.
There are scenarios where this can help, but as you have discovered it does not play well with some other features. A config group contains other config groups/configs.
Hydra 1.1 is adding support for recursive default lists which will make this kind of scenario more common.
See The Defaults List documentation page:
├── server
│ ├── db
│ │ ├── mysql.yaml
│ │ └── sqlite.yaml
│ └── apache.yaml
└── config.yaml
In the scenario from the example there, the entities under server/db are different than the entities under server, so such globing would not make sense.
I have a typo3 extension (created with extension manager) and it seems no matter what I try I always get the following error:
Class CM\Parser\Controller\ParserController does not exist. Reflection failed.
I used the explanations for this problem TYPO3 tutorial extension, controller does not exist and "Controller does not exist. Reflection failed." TYPO3. Neither of them seem to work.
My composer.json in the root directory has the following entry:
"autoload": {
"psr-4": {
"CM\\parser\\": "./packages/cm-parser/Classes"
}
}
My typo3conf/ext folder has a symlink on packages/cm-parser. My composer.json inside the extension directory (packages/cm-parser) has the entry:
"autoload": {
"psr-4": {
"CM\\parser\\": "./Classes"
}
}
Thanks in advance for any help.
My directory structure looks like this (starting in /opt/lampp/htdocs/my-new-project) which is a typo3 v9.5 installation
> .
├── packages
│ └── cm-parser
│ ├── Classes
│ ├── Configuration
│ ├── Documentation.tmpl
│ ├── Resources
│ └── Tests
├── public
│ ├── fileadmin
│ │ ├── _processed_
│ │ ├── _temp_
│ │ └── user_upload
│ ├── typo3
│ │ └── sysext
│ ├── typo3conf
│ │ ├── ext
│ │ └── l10n
│ ├── typo3temp
│ │ ├── assets
│ │ └── var
│ └── uploads
│ └── tx_extensionbuilder
├── var
...
In my typo3conf/ext directory there is a symlink called parser to packages/cm-parser (I think the composer created that for me).
So I hope this symlink works for Typo3.
The files ext_emconf.php and ext_localconf.php are also in the right place. The folder structure above only displays my folders (tree -L 3) up to the third level.
The controller class is CM\Parser\Controller\ParserController, while in your composer.json you're using CM\\parser\\ (with a lowercase p) in the PSR4 autoload. This should be CM\\Parser\\
After changing this you need to of course run composer dumpautoload to reload the autoload information.
In your root composer.json file:
➊ You do not need the PSR-4 autoload section for "CM\\parser\\".
➋ You possibly have to add the path to packages/* as a repository.
➌ You have to include the composer namespace of your extension.
In your file system:
➍ You do not need typo3conf/ext/ as a symbolic link to packages/.
Try the following changes:
In your root composer.json file, remove the PSR-4 autoload section as outlined above. Add the packages/ directory as a path under repositories. For example:
{
"repositories": [
{
"type": "composer",
"url": "https://composer.typo3.org/"
},
{
"type": "path",
"url": "packages/*"
}
],
...
}
Store your extension code in the following path: packages/parser/.
Assuming your extension key reads parser and your vendor name is CM, the composer namespace becomes cm/parser. Add this as a requirement to the composer config file. You can use the following command on the command line:
composer require cm/parser:dev-master
This assumes, that packages/parser/ is a valid Git repository and has the master branch (do not use a version in the extension's composer.json file).
If the local Git repository and version (in the example above: dev-master) can be found, composer will automatically install all dependencies as required and it will create a symbolic link:
typo3conf/ext/parser -> ../../../packages/parser/
Also double check if all PHP files show the correct PHP namespace: CM\Parser\... and your controller class name reads ParserController.
If you can share your TYPO3 extension code, upload it to GitHub (or any other place) and share the link here. This way people can review your code and possibly spot further errors.
Here is the DockerFile.
FROM microsoft/aspnet:4.7
ARG source
WORKDIR /inetpub/wwwroot
COPY ${source:-obj/Docker/publish} .
And here is the error.
Error
Building a.enterpriseextservices
Service 'a.enterpriseextservices' failed to build: COPY failed:
GetFileAttributesEx \\?\C:\Users\jesmiller-AM\AppData\Local\Temp\docker-
builder587295999\obj\Docker\publish: The system cannot find the file specified..
For more troubleshooting information, go to
http://aka.ms/DockerToolsTroubleshooting docker-compose C:\Program Files
(x86)\Microsoft Visual Studio\2017\Community\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets 349
I have published the project to the obj/Docker/publish folder.
Here is my docker-compose file. I used the docker-compose up command from the folder where the docker-compose.yml file is located.
version: '3'
services:
a.web.familyconnection:
image: a.web.familyconnection
build:
context: .\FamilyConnection
dockerfile: Dockerfile
b.enterpriseextservices:
image: b.enterpriseextservices
build:
context: .\Framework\b.EnterpriseExtServices
dockerfile: Dockerfile
I had the same issue. Turned out I made a silly mistake. I added the following to my .dockerignore file, just out of habit when setting up a new project:
bin
obj
.vs
.git
Then I tried running this in my Dockerfile
COPY ./bin/publish/ .
Docker gave the strange tmp path error, because it was falling back to that path since I told it to ignore my /bin folder. Once I copied to a different publish path (not bin), the problem went away.
It looks like your path to the folders, or where you've published your code at may be incorrect. The project should be published in the obj/Docker/publish folder inside of the respective folders defined by context
Using an example docker-compose.yml:
version: "3"
services:
foo:
build: ./foo
bar:
build: ./bar
And Dockerfile:
FROM jaydorsey/ruby-2.4.1
COPY ${source:-obj/Docker/publish} .
And a tree structure like this:
.
├── Dockerfile
├── bar
│ └── Dockerfile
├── docker-compose.yml
├── foo
│ └── Dockerfile
└── obj
└── Docker
└── publish
When I run docker-compose build I get the following error
Building foo
Step 1/2 : FROM jaydorsey/ruby-2.4.1
---> b79899b232f6
Step 2/2 : COPY ${source:-obj/Docker/publish} .
ERROR: Service 'foo' failed to build: COPY failed: stat /var/lib/docker/tmp/docker-builder186649811/obj/Docker/publish: no such file or directory
This isn't identical to yours, since I'm running macOS, but very similar. You'll note the temporary file location (which is an internal Docker artifact of how it's copying files around) and the similarity in the docker-build<randomstring> path
However, if I create the obj/Docker/publish folders underneath each respective subfolder (context), the docker-compose build command works fine.
.
├── Dockerfile
├── bar
│ ├── Dockerfile
│ └── obj
│ └── Docker
│ └── publish
├── docker-compose.yml
├── foo
│ ├── Dockerfile
│ └── obj
│ └── Docker
│ └── publish
└── obj
└── Docker
└── publish
Please check that the folder you've published exists under the contexts as noted, and not in the root.
I still believe this is a path issue as noted in the error message. I hope this provides some context that helps you debug the root cause.
Can you please confirm your file & folder layout? I'm fairly certain it's path related because of the error message. I haven't done any Docker for Windows work either but I'd also double-check your default path using the correct slash (forward vs backward)
I read this article by a fellow stackoverflow member Daniel (hello if you're reading this!) on decoupling Symfony bundles which I found really interesting. I'm now in a position where I am about to start a new project from scratch and have been planning on following Daniel's guidance. However, it was written 2.5 years ago, and Symfony's latest releases haven't adopted the structure and neither is there any mention if it under Symfony's Best Practices article. Therefore, I'm wondering if there's a good reason Symfony themselves have not adopted the structure?
Without reiterating Daniel's whole article here, the directory structure he proposes is as follows (along with not using annotations for entities):
src/
└── Vendor/
└── Product/
└── Bundle
└── BlogBundle/
└── ForumBundle/
└── SiteBundle/
└── Controller/
└── IndexController.php
└── Resources/
└── views/
└── index.html.twig
└── ProductSiteBundle.php
└── Entity
└── User.php
└── Repository
└── UserRepository.php
└── Service
└── UserPasswordRetrievalService.php
In my symfony 2 project I have a bundle at
src/Cinergy/Bundle/PeopleServiceBundle
Now I'd like to generate a CRUD controller based on a doctrine entity, but I'm constantly failing to enter the correct string for the entity parameter.
I tried things like:
php app/console generate:doctrine:crud --entity=Cinergy/Bundle/PeopleServiceBundle:Group
or
php app/console generate:doctrine:crud --entity=#PeopleServiceBundle:Group
All of them return erros like:
[Doctrine\ORM\ORMException]
Unknown Entity namespace alias '#PeopleServiceBundle'.
What's the right syntax for the --entity parameter? Or is there something missing after all?
This is how the directory structure looks right now:
src/Cinergy/Bundle/PeopleServiceBundle/
├── Controller
│ ├── GroupController.php
│ └── PersonController.php
├── DependencyInjection
│ ├── Configuration.php
│ └── PeopleServiceExtension.php
├── PeopleServiceBundle.php
├── Resources
│ ├── config
│ │ ├── routing.yml
│ │ └── services.yml
│ ├── doc
│ │ └── index.rst
│ ├── public
│ │ ├── css
│ │ ├── images
│ │ └── js
│ ├── translations
│ │ └── messages.fr.xliff
│ └── views
│ └── Default
│ └── index.html.twig
└── Tests
└── Controller
├── GroupControllerTest.php
└── PersonControllerTest.php
After all it turned out that I have to create the entity before I can create the CRUD controller for it. Of course that makes sense. Unfortunately the Sensio Generator Bundle documentation does list the operations in the oposite order which pushed me into the wrong direction.
This means the correct order ist
Generating a New Bundle Skeleton
Generating a New Doctrine Entity Stub
Generating a CRUD Controller Based on a Doctrine Entity
First you need to register your bundle into your AppKernel.
Then simply run the following command.
Don't put # before the bundle's name
php app/console generate:doctrine:crud --entity=PeopleServiceBundle:Group
More about generating a CRUD controller based on a Doctrine entity.
According to the symfony docs, you have to use " The entity name given as a shortcut notation containing the bundle name in which the entity is located and the name of tvhe entity", so it should be something like
--entity=CinergyPeopleServiceBundle:Group
If you have more than one Bundle and want to use different database connection just update your config.yml and parameters.yml by adding configuration and parameters.
This will solve problem with CRUD generation.
I searched for hours until I found out that in my app/config/config.yml under doctrine.orm I removed auto_mapping: true which caused the issue. This may be useful for other people :)
If it still relevant for someone :)
guys, it's because DoctrineBundle DoctrineExtension compile the list of valid aliases based on all registered bundles, that have 'Entity' (or other configured) folder in them.
So in order to use doctrine:generate:crud or generate:doctrine:crud,
you have to create just folder Entity in your bundle, and not required to create entity first (as command says - it's true).
So you it will work if you already have some entity in your bundle,
or if you have just empty Entity folder in your bundle.