Set Eclipse project location out of workspace - php

I want to change the source location of a PHP project to be out of workspace in Eclipse.
For example, workspace is in /home/user/workspace/project and source code placed in /var/html/project.
I don't want to make a copy of project in the workspace for two reasons:
Because the source is a git repository and I'm not allowed to change the .gitignore file, I don't want any metadata to be saved in the source folder.
I'm using the source in multiple projects and workspaces.
How to do this?

Just move your project in the filesystem to /var/html/project. Then in eclipse open the File -> Import -> Existing Projects into Workspace dialog. Lookup /var/html/project and leave the checkbox Copy projects into workspace unchecked.

Related

What is the ".phpintel" folder at the top of the Laravel file structure?

I am just noticing that there is a .phpintel folder at the top of the Laravel file structure. Where did it come from, is it necessary and can I gitignore it?
phpintel is a common sublime plugin. PHP code scanner and analyzer for code intelligence within PHP projects.
It creates .phpintel directory like .idea for Phpstorm and it should be included to .gitignore list of project and contains local project related settings and history for it.
You can ignore any hidden (and generated) data
You will find phpintel ignored in many .gitignore project file, such as:
postmark-php/.gitignore
Zizaco/entrust/.gitignore
...

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.

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.

Configuring Eclipse to add a buildpath folder outside the workspace

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.

Categories