“Controller does not exist. Reflection failed.” TYPO3 v2 - reflection

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.

Related

How to apply Artifactory Permission Target to pip, and other non-human-predicatable/readable repo's?

To make Artifactory as self-service as possible for our users, giving permissions to users to deploy to parts of repositories using their personal or team accounts, I'm trying to figure out how to configure this.
For readable directory structure based repositories like anything in the java world, the Permission Targets work perfectly (https://www.jfrog.com/confluence/display/RTF/Managing+Permissions). But I can't find any docs on how to use this for non-human-predicatable/readable directory structures, like PIP, or the flat directory structure, like NPM.
In the java world, repositories have a nicely structured tree like:
~/.m2/repository$ tree org/ | head -20
org/
├── antlr
│   ├── antlr4-master
│   │   └── 4.7.1
│   │   ├── antlr4-master-4.7.1.pom
│   │   ├── antlr4-master-4.7.1.pom.sha1
│   │   └── _remote.repositories
│   └── antlr4-runtime
│   └── 4.7.1
│   ├── antlr4-runtime-4.7.1.jar
│   ├── antlr4-runtime-4.7.1.jar.sha1
│   ├── antlr4-runtime-4.7.1.pom
│   ├── antlr4-runtime-4.7.1.pom.sha1
│   └── _remote.repositories
├── apache
│   ├── ant
│   │   ├── ant
│   │   │   ├── 1.10.1
│   │   │   │   ├── ant-1.10.1.jar
│   │   │   │   ├── ant-1.10.1.jar.sha1
For example, to give teamantl permission to only read, annotate, and write to org/antlr/antlr4-master/**, the following json can be PUT to Artifactory REST API (PUT /api/security/permissions/{permissionTargetName})
{
"includesPattern": "org/antlr/antlr4-master/**",
"repositories": [
"libs-release-local",
"libs-snapshot-local"
],
"principals": {
"groups" : {
"teamantl": ["r","n","w"]
}
}
}
But for example a pip repo is completely hashed:
Which is completely useless in the permission target "includesPattern".
How should this (Permission Targets) work for repo's like PIP, and NPM?
Your screenshot shows a virtual PyPI repo, which is generated and thus hash-structured.
Normally, these are backed by physical repos, filled using twine upload and thus having a ‹pkg›/‹version›/‹file› structure – i.e. perfectly usable as permission targets with package granularity.

Only enable eslint in specific files

I really like eslint for es6 projects. Previously I've used it for new projects. Now I want to add it to a legacy project.
Fixing all pre-existing lint issues in one go is too much effort. Can I configure eslint (in .eslintrc.js) to only check files where I've explicitly enabled it with /* eslint-enable */ or similar?
ESLint has no default-disabled state that can be toggled by a file comment. You might be able to use .eslintignore for this purpose, however. You can ignore everything and then gradually whitelist files as you migrate them by using ! to un-ignore individual files. For example:
.
├── .eslintignore
├── .eslintrc.js
├── package.json
├── node_modules
│   └── ...
├── src
│   ├── index.js
│   └── module
│   └── foo.js
└── yarn.lock
Then your .eslintignore could look something like this:
# Start by ignoring everything by default
src/**/*.js
# Enable linting just for some files
!src/module/foo.js
In this case, src/index.js would be ignored, but it would lint src/module/foo.js.

Spring Boot: Adding static content to web application

I'm using Spring Boot and I want to know how exactly we mention the path to static content in my JSP files?
I tried to make them in src/main/resources/static/css but it was not working, and in my JSP I called them by using:
<link href="<c:url value="/css/bootstrap.min.css" />" rel="stylesheet" type="text/css">
I have no special configuration in my SpringBoot Class just the call SpringApplication.run(...)
Thank you so much for the help!
you have to have configuration that extends WebMvcAutoConfigurationAdapter , it has registry implementation that has automatically scans for some default locations and adds them to classpath
/META-INF/resources/
/resources/
/static/
/public/
Just add,
#Configuration
#EnableWebMvc
#ComponentScan
public class ServerConfiguration extends WebMvcAutoConfiguration{
}
using springboot 1.5.6.RELEASE my folder structure looks like
~/repos/static-content-example/src > tree
.
├── main
│   ├── java
│   │   └── com
│   │   └── example
│   │   └── demo
│   │   ├── DemoApplication.java
│   │   └── MvcConfig.java
│   └── resources
│   ├── application.properties
│   ├── public
│   │   └── test.html
│   └── templates
└── test
└── java
└── com
└── example
└── demo
└── DemoApplicationTests.java
and when I start the server, I can browse to
http://localhost:8080/test.html
http://localhost:8080/public/test.html
anything in the folder "public" is accessible by default at your context root (#1 above). MvcConfig.java allows for #2. I always setup that alias so I can ignore security on any URL that starts with /public. In order to do that without the MvcConfig setup, you'd have to put a folder named public inside the public folder, which is just confusing.
I have no idea why spring doesn't do that by default....seems like it would clear up lots of confusion...

Meteor - correct structure and scope for javascript functions and files?

First of all, I am familiar with what the Meteor docs say about this, which I have summarized here:
Files in subdirectories are loaded before files in parent
directories, so that files in the deepest subdirectory are loaded
first, and files in the root directory are loaded last.
Within a directory, files are loaded in alphabetical order by
filename.
After sorting as described above, all files under directories named
lib are moved before everything else (preserving their order).
Finally, all files that match main.* are moved after everything else
(preserving their order).
(Not sure why they say "moved" instead of "loaded", but I think they just mean "loaded".)
My app has the following structure:
├── client/
│   ├── html/
│   │   ├── main.html
│   │   ├── nav.html
│   │   └── login.html
│   ├── js/
│   │   ├── lib/
│   │   │   └── util.js
│   │   ├── main.js
│   │   └── nav.js
│   └── my_app.less
├── packages/
│   └── some_stuff_here
├── server/
│   └── main.js
├── shared.js
├── smart.json
└── smart.lock
In client/js/nav.js file I have the following JavaScript code:
Template.nav.nav_close = function() {
return ! Session.get(slugify(this.name)+'-nav-close')
}
In client/js/lib/util.js file I have the following JavaScript code:
var slugify = function(value) {
if (value) {
return value.replace(/\s+/g, '-').replace(/\./g, '-').toLowerCase();
}
}
My understanding is that the client/js/lib/util.js file should get loaded first, which will make my slugify function available, and then client/js/nav.js should get loaded and the slugify function should be available to it.
In fact what happens is that I see the following error in my Chrome console:
Exception from Deps recompute function: ReferenceError: slugify is not defined
at Object.Template.nav.nav_close (http://localhost:3000/client/js/nav.js?4d7c7953063828c0e4ec237c1a5c67b849076cb5:2:26)
Why am I getting this error?
slugify has file scope because it is declared with var. Remove var to give it package (application) scope.
Meteor Namespacing
slugify = function(value) {
if (value) {
return value.replace(/\s+/g, '-').replace(/\./g, '-').toLowerCase();
}
}

How to address the bundle in php app/console generate:doctrine:crud

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.

Resources