Eclipse PDT is very slick, but here's my issue, Re: Launcher (run configurations)
I'm trying to keep things very clean, concise on my local machine (with WAMP stack) and I have a number of virtual hosts configured, that keep my URL's easy to use.
In eclipse, I set up PHP servers to correspond with these Vhosts.
Since I have existing code, I'm usually setting up a new project 'from existing sources'.
Then when I try to 'run', I get URL auto-generated like this; with the Project name in it:
http://MyVhost/MyProj/testing.php
And what I really want is:
http://MyVhost/testing.php
I find myself doing a lot of editing and adjusting of the servers and run configurations, before I can get the URL that works. Any recommendations ?
You can create a new Run Configuration Run->Run Configurations and as long as you have setup your virtual hots as servers, you can untick 'Auto Generate' option under URL and enter you URL manually for each project. So even if you point to different files in your project, it won't matter because Eclipse will use your manually entered URL. Save these and then you're done!
The path part of the autogenerated URL is the Base Path (which defaults to / + project name) + the path of the file inside the project location. You can set the Base Path to / in Project | Properties | Debug . It applies to Run configurations as well. If you always use the documentroot of the site as the project location, it will work.
I ran across something similar where if I had a vhost named "test" I wanted to run everything for that project as...
http://test/<whatever_else>/
Here is my 3 step how-to to solve it, though I am not sure of any unintended consequences other than zend debugger not working.
From Eclipse, go to Windows/Preferences
Go to PHP/PHP Servers
Change Default PHP Web Server from http://localhost to http:/
The project will append the second slash and your project name if you just let it auto-generate.
Hope that helps someone. Helped me a ton.
You can modify the org.eclipse.php.server.ui plugin to get it the way you want.
Use the Plugin devlopment perspective of Eclipse to modify the plugin. The dialogs are available in
/org.eclipse.php.server.ui/src/org/eclipse/php/internal/server/ui/launching/PHPWebPageLaunchShortcut.java
/org.eclipse.php.server.ui/src/org/eclipse/php/internal/server/ui/ServerLaunchConfigurationTab.java
https://vsubhash.wordpress.com/2013/01/26/fix-for-url-auto-generate-bug-in-eclipse-php-pdt-plugin/
Related
Currently I am trying to run a Wordpress repo locally for development. I am not using MAMP pro even though I still have a 9 day trail. I figured since I'm going to be using the free version for now I might as well work with that. I have my Apache & MySQL server running along with the Document Root pointing to my Sites folder where my projectName repo sits. I'm still running off of the default port of Apache 8888.
After I start the servers, I open WebStart and import my DB into phpMyAdmin. Everything works perfectly fine and the copy of my db gets imported. I then make sure that my wp-config.php file has the appropriate settings to access this db. I then click on My Website. This pulls up the content of the website. However, it does not pull in any of the assets(imgs/js/css). I receive the following errors in the console:
Failed to load resource: net::ERR_EMPTY_RESPONSE http://projectName.dev/wp-content/uploads/2016/09/logo-footer-1.png
Failed to load resource: net::ERR_EMPTY_RESPONSE http://projectName.dev/wp-content/themes/projectName/images/circle.png
And so the list goes on and on for pretty much every asset the project could possibly have. Now configuration is NOT my strong suit, and at this point I am at a loss of what could possibly be happening. Awhile ago I did follow a tutorial on how to setup my files so that I can access them in the web browser by simply typing the name of the project with the domain .dev, example: projectName.dev. I started having issues with this after upgrading to OS Sierra and it no longer works. Could this possibly be the reason as to why it is looking for these assets in the projectName at the .dev domain?
I apologize if this does not make sense. I am willing to provide anyone with any information on this as I need as much help as possible because I still need to level up my configuration skills. Let me know if you have questions.
The images and other assets are referenced with an absolute filepath (i.e. the URL of the server on which you first set it up). This has to be changed in all database entries. There are tutorials for this on the net, but the most simple version is to open the sql file in an editor and search & replace the general URL part in the complete database.
Be sure to keep a backup of the file - that might not work on the first try...
A year ago, I decided to go with codeigniter instead of laravel, because codeigniter prooved to be easier to setup. I am now preparing for my next project and it seems as if codeigniter is now obsolete (at least most of the people seem to recommend laravel over codeigniter).
Now to my problem: I use a virtual ubuntu machine for developing web apps so I have a dev environment similar to the production environment (this helps me to avoid some problems (especially case-sensitivity...;)))
I installed composer and laravel and created a new laravel project named "quickstart" in /var/www/quickstart. I then followed their "getting started guide" (here: Guide). So far everything worked.
But here come the problems:
I have two other web applications in /var/www, so when I enter the ip of the machine I see the 3 directories.
Issue 1:
Normaly I'd expect that as soon as if I click on the "quickstart"-Directory in my browser, the webapp would get displayed, but I have to click a second time on "public", and then the webapp is displayed.
Issue 2: Of course, the links on the page are wrong too, because they reeer to (for example) "/task", which can't be found on the server.
The problem is that I'm not really experienced with apache configuration. I suspect it has something to do with VirtualHosts, but AFAIK you need to have root access to configure virtual hosts, and I do not have root rights on the dev environment.
Could you point out a way to me how I can make laravel work in a subdirectory in a way that I can just move the files and folders to my hoster as soon as I have finished the project? I'd like to then change only one file, and not all paths and URLs in all files ;)
Regards,
Christian
Thanks to Bogdan, I was able to figure it out. My hoster allows symlinks, so I did it like so:
I put the laravel installation in
/srv/web/quickstart
(quickstart is the name of the project). I then created the following symlink:
ln -s /srv/web/quickstart/public /srv/web/www/public
The document root of the apache is configured to
/srv/web/www/public
After that I just got a blank page. That was because I forgot to set the correct permissions on the storage-folder. So I set the following permissions
chmod -R 777 /srv/web/quickstart/storage
This is fine for a development environment. For production I'd recommend to only allow the webserver-user to write into that directory.
And voilĂ : Everything works!
Thank you for your help bogdan.
Christian
I've just imported a largish php project into NetBeans. Under the top directory I have "app1", "app2", "app3", etc. (each of which are mapped to a domain name), then a "shared" directory for (you guessed it) files used by all the apps.
In app1/route/Search.inc it has:
include_once "../shared/lib/search.inc";
But ctrl-B on this line does nothing. Makes sense, from NetBeans point of view of this as one large application, it should be "../../shared/lib/search.inc". But, for the way the apps are configured, the above is correct, and NetBeans is wrong.
How do I tell NetBeans it needs to go one extra directory up?
Under Include Path, I tried adding "/full/path/to/app1" (so then "../shared/lib/" would be found) (I tried Private tab, then Shared tab, with same results.) But it rejects that, telling me the app1 directory is already part of the application. There is no "Do what I say, and don't think about it, slap!" button.
Adding symbolic links in the file system, just for NetBeans, feels a bit ugly.
I'm wondering if I should make one NetBeans project per app? (I actually tried that first, but as all apps are in the same git repository it gave a lot of noise, so I assumed that was the wrong way.)
ADDITIONAL: I'm most interested in the answer to my last question - is it standard practice to keep each app as a separate NetBeans project, even if they are all in the same git repository?
Product Version: NetBeans IDE 8.0.2 (Build 201411181905)
Updates: NetBeans IDE is updated to version NetBeans 8.0.2 Patch 1
Java: 1.7.0_79; OpenJDK 64-Bit Server VM 24.79-b02
Runtime: OpenJDK Runtime Environment 1.7.0_79-b14
(on linux Mint 17)
Make shure that all files of your project are in the project's include path (righ click project -> properties -> include path). Usually there is only the "global include path", which you configure in the NetBeans settings (e.g. to point to your PEAR directory). Add all directories which contain source code you want auto completion for to this include path. Hint: This include path has nothing to do with the include_path used in PHP itself.
I'm wondering if I should make one NetBeans project per app? (I actually tried that first, but as all apps are in the same git repository it gave a lot of noise, so I assumed that was the wrong way.)
Yes you should have different NetBeans projects if your apps are separate, and since they are on different domains, it sounds like they are pretty distinct.
One way you can reduce the noise level of this approach is to right click the other app directories and find the option to Mark directory as > excluded and it should disappear (and the files won't be indexed for autocomplete / search / etc).
I have no problems with such a scenario, if I only select the filename. Then NetBeans search for a file with this name in the whole project directory.
If I select the filename and the path, it does not work. Maybe that is your problem?
I have changed nothing else and it works like a charm.
there is a alternative way to set path i.e. via php.ini
add the following line in php.ini set path of
include_path = ".:c:\xampp\htdocs\project_name\your_include_folder_name"
restart the apache server
I installed Eclipse PDT for PHP development on my Ubuntu box (running Apache2 as server),
I tried to create a PHP project and run it as "PHP Web Application" as show in the picture:
But when I click "Run" the browser pops out and giving 404 error saying it cant find localhost/test/newfile.php .
Does Eclipe PDT having its own internal webserver? (If so, I tried by shutting down my Apache2 ,but still giving the same error)
Finally, as a work around, I changed my workspace location to "/var/www" and created my projects there. But wondering whether its the best way to develop using PDT?
The questions you ask are not directly related to Eclipse PDT but how to setup the development server.
I suggest not to move the project into the webroot but to make Apache visit your development/project directory instead.
There are multiple ways to do that:
You can create a symlink (softlink) making a URL-Path point to a directory. You need to allow Apache to follow symlinks.
You can make use of the Alias directive to do something similar.
Virtual Hosts to make the webserver point to the location you're looking for via it's domain name. You can then create "fake" domain names within your hosts file like example.com.loc for the local development version of your website.
You can even use mod_rewrite for that (not that good option).
As you can see there are multiple ways to have this in a manageable fashion. Depending on your needs, the symlink variant is probably most easy to accomplish. If you need more security, the Alias Directive is similarly easy to accomplish. Virtual hosts start to make sense if you're more familiar with apache configuration and you need more control of the URLs (some software is that dumb that it needs to reside on the top path / beneath an URL otherwise it just does not work (yeah, crap, but virtual hosts come to the rescue then). The mod_rewrite "solution" is just named for completeness reasons, it's more asking for trouble if you're not firm with mod_rewrite and as you're new to apache configuration, leave it next to your road and ignore that suggestion.
All these ways allow you to have one or more development projects next to static websites on your server. I personally have configured virtual hosts on my devbox, and on my earlier devbox I was just using alias directives.
Keep in mind that you need to restart the apache service if you edited the configuration:
$ sudo /etc/init.d/apache2 restart
And most importantly: Before you edit the configuration file, copy it over to a backup file-name. Always backup configuration files before you edit them. You don't want to loose the working settings, believe me ;)
I've been reading through the docs and testing out what i can.
I've installed PHP, Eclipse + PDT, IIS settings etc. - I'm reasonably sure they are all set and should work.
Now I create a PHP Project, add a newfile.php, basic code like :
<?php
echo "hello";
Now I right click the file,Run as -> Web Page and i get a 404.
Eclipse has tried to launch http://localhost:80/Php1/newfile.php
IIS has no virtual or physical directory so the request fails.
Should Eclipse/PDT have done this mapping? Or do I need to? or should I create my projects under c:\inetpub\wwwroot
Eclipse / PDT does not configure your webserver for you. It looks like it's assuming that your document root is your workspace, so you could put all your projects in your wwwroot if you wanted to. You don't need to use the Run As dialog though, as long as the files are somehow visible to IIS.
Personally I like to either make a vhost per project, or use symlinks to bring the project directories into the wwwroot.