I have a listener called LoginListener which works, but for some reason randomly i get this error when making a request for a route. If i then refresh it doesn't happen, then will randomly happen again.
Expected to find class "App\Security\LoginListener" in file
"/home/nibbrstaging/webuyanyhouse.nibbrstaging.com/api/src/Security/LoginListener.php"
while importing services from resource "../src/*", but it was not
found! Check the namespace prefix used with the resource in
/home/nibbrstaging/webuyanyhouse.nibbrstaging.com/api/config/services.yaml
(which is loaded in resource
"/home/nibbrstaging/webuyanyhouse.nibbrstaging.com/api/config/services.yaml").
I've noticed this a few times when i say edit a controller and add a new route, it will then throw this error. If i then come in and delete a bunch of white space in the new controller method it goes away.
It's a strange issue this, has anyone seen this happen before and how to solve it?
It does this in dev mode as well as prod, here is my auto load config:
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
Related
I want to run mutliple requests in a single module, just like here https://docs.integromat.com/apps/app-blocks/api/multiple-requests
The issue is, the first URL is never called, only a second one and the temp variable is null. When I remove second URL the first one is called properly, could you guys please advise?
Here is the code, one of my tests but no matter what I do, first line is not executed, temp var is null. When I comment out second URL the first one is executed properly.
[
{
"url": "/users/{{parameters.clientID}}/conversations/",
"response": {
"temp": {
"conversationID": "{{body.results}}"
}
},
"url": "/conversations/{{temp.conversationID.1.id}}/",
"response": {
"output": "{{body.results}}"
}
}
]
Thanks!
When I generate a new bundle I receive the error notice that kind:
"Fatal error: Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "myBundle" from namespace "my\myBundle".
Did you forget a "use" statement for another namespace? in C:\wamp64\www\symfony\app\AppKernel.php"
in autoload section of composer.json replace the entry
"psr-4": { "AppBundle\\": "src/AppBundle" },
for
"psr-4": { "": "src/" },
then execute composer dumpautoload.
that worked for me.
I've started to learn Symfony and I am following some tutorials where there is nothing about this:
When I create a new project with symfony installer and run composer install and then php app/console server:start I can open that project in my browser.
BUT! When I create a new bundle with command php app/console generate:bundle I get this error message:
PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "BlogBundle" from namespace "BlogBundle".
Did you forget a "use" statement for another namespace? in /home/user/Symfony/myapp/app/AppKernel.php:19
And then I need to go to my composer.json file and append my new generated bundle after AppBundle like this
{
"name": "user/myapp",
"license": "proprietary",
"type": "project",
"autoload": {
"psr-4": {
"AppBundle\\": "src/AppBundle",
"BlogBundle\\": "src/BlogBundle" // <-- this is the new appended one
},
"classmap": [
"app/AppKernel.php",
"app/AppCache.php"
]
},
..........
And then when I try to start the server again it works and it shows Hello world in my browser.
So the question is do I have to do this every time (append new generated bundle in composer.json file)?
Yes. This is the reason, why you usually have an namespace above that. Some abbreviation of your name or company for example. This way you only add that namespace for the src folder and all bundles are "found" automatically.
Example:
{
...
"autoload": {
"psr-4": {
"Acme\\": "src"
},
}
...
}
Now of course your bundles need to use that namespace, eg.:
namespace Acme\BlogBundle;
class BlogBundle {
}
I'm running phpunit and it gives me an error
PHP Fatal error: Class 'MyApp\MyBundle\Tests\Units\Classes\Action\ActionTestCase' not found in /var/www/src/tests/src/MyApp/MyBundle/Classes/Action/KeywordTest.php on line 7
In that class is
5 use MyApp\MyBundle\Tests\Units\Classes\Action\ActionTestCase as TestCase;
6
7 class KeywordTest extends TestCase {
The thing I can't understand is, ActionTestCase exists, but at MyApp\MyBundle\Classes\Action\ActionTestCase
When I use the autocomplete function of PhpStorm, it uses the path with the \Tests\Units part. That is the only path it finds, and if I double click in there it directs to the correct class. And yet PHPUnit doesn't find it.
Where is this extra path being added? In PhpStorm or Composer or somewhere else?
The composer.json file includes this
"autoload": {
"psr-0": {
"": "src/"
}
}
,
"autoload-dev": {
"psr-4": {
"": "src/tests"
}
},
The phpunit.xml file includes this
<phpunit bootstrap="app/autoload.php">
Moving tests out of src sounds like a good suggestion (regarding Jakub Zalas comment), you can better say if that is an option for you or not.
Regardless of that, the dev autoloader is not correctly configured for that path:
"autoload-dev": {
"psr-4": {
"": "src/tests"
}
},
Would look for the file
src\tests\MyApp\MyBundle\Classes\Action\ActionTestCase.php
but you have the file at
src\tests\src\MyApp\MyBundle\Classes\Action\ActionTestCase.php
^^^
Adding the missing src/ part should make it working:
"autoload-dev": {
"psr-4": {
"": "src/tests/src/"
}
},
Don't forget to dump the autoload again:
composer dump-autoload
after you change the composer.json.
Yeah it's just the initial browser load or two after a cache clear. Subsequent refreshes clear the problem up.
I'm thinking the item views just aren't fully constructed in time to be used in the collection views on the first load. But then they are on a refresh? Don't know.
There must be something about the code sequence or loading or the load time itself. Not sure. I'm loading via require.js.
Have two collections - users and messages. Each renders in its own collection view. Each works, just not the first time or two the browser loads.
The first time you load after clearing browser cache the console reports, for instance:
"Uncaught ReferenceError: MessageItemView is not defined"
A simple browser refresh clears it up. Same goes for the user collection. It's collection view says it doesn't know anything about its item view. But a simple browser refresh and all is well.
My views (item and collection) are in separate files. Is that the problem? For instance, here is my message collection view in its own file:
messagelistview.js
var MessageListView = Marionette.CollectionView.extend({
itemView: MessageItemView,
el: $("#messages")
});
And the message item view is in a separate file:
messageview.js
var MessageItemView = Marionette.ItemView.extend({
tagName: "div",
template: Handlebars.compile(
'<div>{{fromUserName}}:</div>' +
'<div>{{message}}</div>' +
)
});
Then in my main module file, which references each of those files, the collection view is constructed and displayed:
main.js
//Define a model
MessageModel = Backbone.Model.extend();
//Make an instance of MessageItemView - code in separate file, messagelistview.js
MessageView = new MessageItemView();
//Define a message collection
var MessageCollection = Backbone.Collection.extend({
model: MessageModel
});
//Make an instance of MessageCollection
var collMessages = new MessageCollection();
//Make an instance of a MessageListView - code in separate file, messagelistview.js
var messageListView = new MessageListView({
collection: collMessages
});
App.messageListRegion.show(messageListView);
Do I just have things sequenced wrong? I'm thinking it's some kind of race condition only because over 3G to an iPad the item views are always undefined. They never seem to get constructed in time. PC on a hard wired connection does see success after a browser refresh or two. It's either the load times or the difference in browsers maybe? Chrome IE and Firefox on a PC all seem to exhibit the success on refresh behavior. Safari on iPad fails always.
PER COMMENT BELOW, HERE IS MY REQIRE BLOCK:
in file application.js
require.config({
paths: {
jquery: '../../jquery-1.10.1.min',
'jqueryui': '../../jquery-ui-1.10.3.min',
'jqueryuilayout': '../../jquery.layout.min-1.30.79',
underscore: '../../underscore',
backbone: '../../backbone',
marionette: '../../backbone.marionette',
handlebars: '../../handlebars',
"signalr": "../../jquery.signalR-1.1.3",
"signalr.hubs": "/xyvidpro/signalr/hubs?",
"debug": '../../debug',
"themeswitchertool": '../../themeswitchertool'
},
shim: {
'jqueryui': {
deps: ['jquery']
},
'jqueryuilayout': {
deps: ['jquery', 'jqueryui']
},
underscore: {
exports: '_'
},
backbone: {
deps: ["underscore", "jquery"],
exports: "Backbone"
},
marionette: {
deps: ["backbone"],
exports: "Marionette"
},
"signalr": {
deps: ["jquery"],
exports: "SignalR"
},
"signalr.hubs": {
deps: ["signalr"],
exports: "SignalRHubs"
},
"debug": {
deps: ["jquery"]
},
"themeswitchertool": {
deps: ["jquery"]
}
}
});
require(["marionette", "jqueryui", "jqueryuilayout", "handlebars", "signalr.hubs", "debug", "themeswitchertool"], function (Marionette) {
window.App = new Marionette.Application();
//...more code
})
Finally, inside the module that uses creates the collection views in question, the list of external file dependencies is as follows:
var dependencies = [
"modules/chat/views/userview",
"modules/chat/views/userlistview",
"modules/chat/views/messageview",
"modules/chat/views/messagelistview"
];
Clearly the itemViews are listed before collectionViews. This seems correct to me. Not sure what accounts for the collectionViews needing itemViews before they are defined. And why is all ok after a browser refresh?
The sequence in which you load files is most likely wrong: you need to load the item view before the collection view.
Try putting all of your code in the same file in the proper order, and see if it works.
The free preview to my book on Marionette can also guide you to displaying a collection view.
Edit based on calirification:
The dependencies listed for the module are NOT loaded linearly. That is precisely what RequireJS was designed to avoid. Instead the way to get the files loaded properly (i.e. in the correct order), is by defining a "chain" of dependencies that RequireJS will compute and load.
What you need to do is define (e.g.) your userlistview to depend on userview. In this way, they will get loaded in the proper order by RequireJS. You can see an example of a RequireJS app here (from by book on RequireJS and Marionette). Take a look at how each module definition decalre which modules it depends on (and that RequireJS therefore needs to load before). Once again, listing the modules sequentially within a dependecy array does NOT make them get loaded in that sequence, you really need to use the dependency chain mechanism.