Configuring Eclipse to add a buildpath folder outside the workspace - php

I'm developing PHP on a mac. As per other suggestions, I've set the workspace to be in the HTDOCS folder of MAMP.
Unfortunately, this means I cannot use links to '/' as I would in production. Any suggestions?
Relatedly, the workspace seems to prevent references to build paths outside the workspace, yet I would Like to keep my sensitive files outside the base workspace folder. Is there a way to do this?

I usually use the "link" feature:
select folder in which you want to create the link (i.e. root itself);
right-click -> new -> Folder
click "Advanced" button
check "Link to folder in the filesystem" and browse for the folder under htdocs
This should help

I have no experience using eclipse with PHP, but for Java, you can "Add External Class Folder" in the "Libraries" tab of the Build Path dialog. Generally, anything that's outside the workspace is called "external" and accessible only through such special options.

Related

Is there a way to create an Eclipse project excluding the project name in the path?

Not sure how I can explain this better as I am a beginner to Eclipse application.
I have my web directory set up for php pages. For example, /home/www/phpsite. All the source files exist here.
However, whenever I create a project (say 'myProject') and test any files from the existing path, it includes the project folder in the path name:
/home/www/phpsite/myProject/index.php
and this results 'Not Found' error.
How can I run my php pages in /home/www/phpsite/index.php? The project folder name is always included in testing web pages.
I am not trying to use the workspace directory created by Eclipse. I'd like to code and modify pages directly from Eclipse to my web directory.
Thanks
Follow these steps:
Setup www as your workspace
From the menu: File -> Import -> General -> Existing Folder.....
Promote to project:
Choose project type: PHP
Browse for "phpsite" and finish.

Can you turn a folder of PHP files into a netbeans project?

I have a folder with several subdirectories containing PHP files. At the moment I open each file individually in Netbeans. However, I would like to open this folder as a project, so I can use features like searching for a line throughout the entire project. Is this possible in Netbeans? What would be the best way to achieve this?
Create a new project, set sources directory to the one you have with current files
(might want to back up the files before if anything goes wrong).
Go in Netbeans. Select Files->New Project. A window will open, in that select PHP in Categories. Click Next. In Project Name give the name of your project(as seen in netbeans), in Sources Folder select the path to your project and click Next. In Run Configuration Make the settings according to your requirement to run the project. Now in PHP Frameworks Select ypur desired framework or just leave it blank and click FINISH.
You will See your project in Netbeans now.
Go to file->New Project and select PHP in category and follow the instruction.
In Source folder you need to choose your files folder so that it get listed.
go to FILE->new Project->select php in categories in left pane and php application with existing sources as Projects *in the right pane* ->next -> next till finish
When you add any directory in netbeans as a project, it add its only directory under the project directory. So if you need to add the numbers of directory in netbeans being a project, then i would like to suggest firstly to collect all directory in parent directory. then add it as a project.
Here is an explaination:-
directory- dir
lets you have dir1, dir2, dir3, dir4.
and according to you mentioned above all dir are projects.
You have to create a dirA and all dir1, dir2, dir3,and dir4 are subdirectory of dirA.
so the folder under dirA nbprojects(created by netbeans) will take care of all directories being the subdirectory of dirA.

phpstorm, subdomain handling

I have a project with some php and html files. URL for this project, for exmaple, - mysite.com
I need to create a subdomain for content, that will be moved to CDN: assets.mysite.com
Now, during development time, all files for subdomain are stored in a subfolder of my project /home/user/phpstormprojects/mysite/assets
In my html/php files I need to specify full path to my assets
html://assets.mysite.com/mybest.png
Of cource I want autocompletion and other features to work well.
So I need to set up phpstorm smth like "assets.mysite.com" = "/home/user/phpstormprojects/mysite/assets"
Could I do it?
I am using PhpStorm 7.1.3
Ensure your cursor has highlighted the project name.
At the menu on top select "File" then "New" then "Directory".
Name your directory. It will go under the project name (see step 1).
Right click on the new directory then select "Mark Directory As" a
pop-up will appear giving you the option to mark the new directory
as "Resource Root".
Put whatever directories you want inside it. PhpStorm will rename all references to them in your code.

How to add project to Netbeans when all source files are not in webroot?

The directory structure of my project is like this:-
/var/www/includes/
/var/www/classes/
/var/www/public/css/
/var/www/public/js/
/var/www/public/index.php
The webroot is /var/www/public, so accessing the test domain localhost.dev would serve the files inside the public directory and hence would run /var/www/public/index.php. No need to access like localhost.dev/public/index.php
The problem is when I create the project in Netbeans, I have to set the index file so that the project can be debugged using xdebug and Netbeans.
So when adding the project I provided /var/www as Project source folder (Sources Folder) as the includes and classes are in this folder. In the next project configuration screen (Choose Project > Name and Location > file path is taken as Run Configuration), I'm asked for the Project URL and the index file. Since the index.php file is actually under the /var/www/public/, when I browse the file and select it, the url to index page is taken as localhost.dev/public/index.php instead of just localhost.dev/index.php. This is preventing me from debugging the project.
Can anyone please point out how to add projects to Netbeans when all the source files are not in web root and the project is to be debugged using xdebug.
I think its a bad practice to put all the project files directly in /var/www.
I think you will never see that in real deployed projects. So my first recommendation will be to change the way you are structuring your project. If that's not possible, in Netbeans select /var/www/public as the Project folder.
If Netbeans need references to the folders in /var/www, create symbolic folders inside public pointing to those in /var/www.
The last resource you have is to create a rewrite rule in Apache to make localhost.dev/public be the same as localhost.dev. You can look for this in Apache documentation.
I have a similar set up with one minor difference: my setup uses a remote site on my local development server. On the "Run Configuration" window of the project properties, I set "Run As" to "Remote Web Site (FTP, SFTP)". I don't think this affects the information in my answer, but I'm mentioning it just in case.
Go to the "Sources" window of your project properties, find the entry for "Web Root", click "Browse" and select the /var/www/public directory. That should cause xDebug to use localhost.dev/index.php. You'll notice when you go to the "Run Configuration" window and browse for the Index File that the browse window will start in "public" rather than "www".
An important note about this type of configuration that caused me a great deal of frustration.
When using xDebug, you'll want to be able to set breakpoints in and work with the files outside of the web root (public) directory. Because you've set the web root to /var/www/public, you won't be able to work with the files in /var/www/includes or /var/www/classes.
The thing you need to do is to add the files outside of your web root to the Global Include Path.
There are two methods for adding directories to your Global Include Path, which one you use depends on how you've configured your project.
In your case, the external directories are included in your project, so you need to add them via the "Options" interface. Go to Tools->Options and select the "PHP" tab, then add the /var/www/includes and /var/www/classes folders to the Global Include Path.
The other method for adding files to the Global Include Path is for files that are located outside of your project source folder. For directories like /var/folder_outside_www/, you use the "PHP Include Path" window in the project properties.
I haven't found a better way but I use this steps:
Menu:Project Properties -> Link:Run Configuration -> Button:Advanced
Debug URL, choose: Ask Every Time
Path Mapping, Server Path: http://localhost.dev/ ,Project Path: /var/www/public/
Now, when you start Debugging process, Netbeans will display Specify URL pop-up which you can change from http://localhost.dev/public/index.php into http://localhost.dev/index.php
Set /var/www/public as project folder (contain netbeans project folder) and include in project properties /var/www/includes/ and /var/www/classes/ as global include directories. Or best way use PHPStorm.

How can I change project resource location in a project?

I use Eclipse PDT and have setup some PHP projects. The resources for one project had to be moved into a different folder. Can I change the resource location without deleting the project an setting up a new one?
Via "Projects -> Properties" I can only see the location path, but I can't change it.
Right-click on the project -> Refactor -> Move
Or close the project, delete it (but do not delete content on disk), use terminal or file browser to move the project folder on disk, in Eclipse click File -> Import -> General > Existing Projects into Workspace ...
You can at project level use refactor>move to move that code to a new location
Not sure if that is exactly what you want.
You can move the location by right click on the project folder, then Refactor->Move...
Then Browse to new folder, note that new location can not be in the current workspace.

Categories