I have a class in a directory classes in the root directory of a Yii 2 project. Let's call this class as FirstClass. It is namespaced as app\classes.
To accomplish a particular task, another class called ApplicationProcessor inside the vendor directory needs to instantiate FirstClass. However, FirstClass cannot be accessed. I tried passing app\classes\FirstClass to ApplicationProcessor but it doesn't work.
What should I pass to ApplicationProcessor so that it can locate the class in the root directory of the Yii 2 project?
Related
I've noticed when I move a file in PHPStorm, it doesn't adjust the namespace at all. My project uses PSR-0, so directory structure mirrors the namespacing. Is it possible to have PHPStorm adjust the namespace when a file is moved?
Also, when renaming a file the class name is not changed and I then have to go in and rename the class. Is it possible to rename a file and the class in a single step?
I'm using 7.1.3
I encountered the same issue. The reason was that I was trying to move the file (from project view), instead of moving the class (right click on the name in the source code).
If you use the F6 refactoring, it will allow you to move the class and change the namespace at the same time: PHPStorm docs
However, you do need to have the directory namespace mappings setup:
Because my application is a Laravel app the root directory was not the source of the namespacing. PHPStorm has a new option as of 8.0 that allows you to specify a directory as the namespace root: http://youtrack.jetbrains.com/issue/WI-22585
i just wanna access the public class which is 2 levels outside from the fla file. My folder structure as follows.
com
displays
main.fla
Some fla's are located in displays folder. And i want to access the globalvar.as from fla's which is located in displays folder.
Before anyone can help you - you need to get your terminology right. You want to access a class programatically, not an '.as' file (even if the .as file contains the definition of the class). And you want to access it from another class, not from a '.fla' file.
Anyway, what you need to do it import globalvar.as in the class that needs to access it, and (assuming it's a static class, which it should be) just access it like this globalvar.myVarName (where 'globalvar' is the case-sensitive name of the class, and 'myVarName' is the name of the var you want to access).
Using an IDE like Flash Builder (which is an excellent product) makes this sort of thing much easier - if you're interested in AS3 development I would really recommend it.
I have too many modules (around 90) in my project.
But I want to keep individual displaytag.properties file for each module rather than having single file for whole project.
How to achieve this.
I am using struts2
I think that you can configure each displaytag using the appropiate bundle, remember the bundle search order from S2 docs:
ActionClass.properties Interface.properties
Interface.properties (every interface and sub-interface)
BaseClass.properties (all the way to Object.properties)
ModelDriven's model (if implements ModelDriven), for the model object repeat from 1
package.properties (of the directory where class is located and every parent directory all the way to the root directory)
search up the i18n message key hierarchy itself
global resource properties
and from the docs for the DisplayTag library:
For the whole web application, create a custom properties file named "displaytag.properties" and place it in the application classpath. Displaytag will use the locale of the request object to determine the locale of the property file to use; if the key required does not exist in the specified file, the key will be loaded from a more general property file.
so i guess that the displaytag will search the config keys in the s2 available bundles.
Hi i am using struts2 and hibernate in my project. I need to use a namespace for my admin section so that i have used the namepace as companyAdmin and i have created a folder inside the web folder named companyAdmin and it is worked fine. But when i delete the folder companyAdmin from the web folder the struts show an error error message when trying to access the namespace. Is there a folder with name as namespace name is a must in struts2 for using the namespace. Also i can't able to use the namespace as "admin" even though i have created a folder in the web folder with a name admin.
Please be clear that Struts2 namespace is nothing related to folder/any other resource in your web-application.
Namespace inside Struts2 subdivides action configurations into logical modules, each with its own identifying prefix.Namespaces avoid conflicts between action names.
This is what doc say about namespace
Namespaces are not a path!
Namespace are not hierarchical like a file system path. There is one namespace level. For example if the URL /barspace/myspace/bar.action is requested, the framework will first look for namespace /barspace/myspace. If the action does not exist at /barspace/myspace, the search will immediately fall back to the default namespace "". The framework will not parse the namespace into a series of "folders". In the Namespace Example, the bar action in the default namespace would be selected.
I suggest you to go through the official documentation of Namespace to get an idea what they are and how they work inside S2
namespace-configuration
I have a process set up to create action script files. They hold functions that are called upon by my flash project. How can i reference these files so that the project knows the functions are there.
with asp.net i would simply reference the .js file. Is it the same process?
The process of importing files to be used by Flash is pretty straightforward:
At the top of each external file there will be a package declaration, it basically represents it's path from the .fla file.
For example:
package com.site.objects
The above represents an ActionScript file within a folder objects, within site, within com whose parent folder also contains the .fla file.
When you're importing external files, you always start from the directory containing the .fla. This is always necessary with the exception of importing external files that are in the same directory as the file you're trying to access the class from.
The import statement for the above example will look like this:
import com.site.objects.MyClass;
Once you've done this, you'll be able to:
Create instances of the imported class.
Access static properties and methods defined within the class.
Extend the class to create a new class which will inherit it's properties.
etc