How to setup PhpStorm to debug OctoberCMS - phpstorm

I have tried debugbar, but this does not give me enough information.
I have also tried setting up OctoberCMS using that same method to debug as I would with Laravel, but when I set a break point it stops at index.php. Also, I have tried the validation script inside PhpStorm, but it gives a 404 error.
I am trying to debug a plugin that I am developing, and it would be easier using an IDE like PhpStorm or NetBeans. Any help would be appreciated.
I have setup phpstorm to debug a laravel project by setting the URL:/phpstorm/public in the PHP Web Page settings but when I try some thing simular in my octobercms project all I get is waiting for connection meaning that the break point never gets hit here are the setting I am using
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port= 9000
xdebug.remote_autostart=1
xdebug.profiler_enable=1
xdebug.profiler_output_dir ="c:/wamp64/tmp/"
xdebug.idekey=PHPSTORM
in the PHP Web page I have
start URL: /octobercms/backend/rainlab/blog/Posts
I have not set path mappings in the server as did not do this for the Laravel project I am using WAMP64 with the following settings c:/wamp64/www/octobercms/
and this is my vitrual host file
<VirtualHost *:80>
ServerName octobercms.test
DocumentRoot "c:/wamp64/www/octobercms"
<Directory "c:/wamp64/www/octobercms">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
DirectoryIndex index.php index.html
Require local
</Directory>
</VirtualHost>
any advise on the setting I should use for Octobercms would be helpful

I am not sure if this helps but after several attemps to get this to work I managed to get phpstorm to stop at the breakpoint I selected by the following
Set up wamp up as above
In the PHP Web Page section I set the Start URL: to
/octobercms/backend/rainlab/blog/posts and apply settings
Set a break point in Posts.php
pressed the run button
and all is well with the world, I can now try to figure out why my plugin is not doing what its supposed to.

Related

How do I make a custom 'File not found(404, 500)[http error code]'for my website

I have seen some websites have their own File not found pages with their logos.
I want such a page for my website.
Please tell me how to make a such type of page that shows the user if the file is not found.
First of all you need an HTML or PHP file to show when the 404 is occurs. Let's do a simple HTML file like this:
<h2> 404 Not Found! </h2>
<pre> Seems like the resource you're looking for is not found </pre>
Let's call this file 404.html.
Now you have to configure your webserver to redirect the not found request to your new HTML document.
If you're using Apache:
You can do it in different ways, the most common and recommended would be using .htaccess file, which allows you to override Apache configuration of a virtual host. However, to be able to use the .htaccess file in your virtual hosts you need to add allowOverride all inside your apache configuration.
Example of apache config:
<Directory /path/to/your/project>
Options FollowSymLinks
AllowOverride All # This is the needed option
Order allow,deny
Allow from all
Require all granted
</Directory>
So now you're able to put a .htaccess file in your project, so just create it and put this inside:
ErrorDocument 404 /path/to/404.html/document
In case you're using Nginx:
You must add the error page inside the nginx configuration. Follow this guide in order to achieve it:
https://www.digitalocean.com/community/tutorials/how-to-configure-nginx-to-use-custom-error-pages-on-ubuntu-14-04
if you are using Apache server
in your project folder
consider your project is in
/mySampleProject
create .htaccess file in /mySampleProject if you don't have one.
simply add this line in your .htaccess
ErrorDocument 404 /yourCustom404Template.html
I will suggest you, use a framework of whatever programming language you want to build this application. They have in-built custom arrangements for such requirement e.g.
if( file_not_found Logic ){
show 404_page
}

How to fix website internal navigation/ Joomla

I have a situation to which I cannot seem to have a fix for !
The thing is I'm hosting a website on localhost (LAMP).
The website is created using Joomla Framework. The home page loads successfully when I navigate to the website on the localhost.
As soon as I click on any navigation links, a 404 error is displayed.
eg. homepage URL -
http://localhost/PortalSources/
Nav link -
http://localhost/PortalSources/tools/safety-assessment-tool.html
As soon as I manually add 'index.php' to the nav link
http://localhost/PortalSources/index.php/tools/safety-assessment-tool.html
the link starts to work and page loads successfully.
What could possibly cause this behavior ? How do I fix it so that I don't have to manually type in for every page on the website ?
You can probably find your answer here: https://docs.joomla.org/Enabling_Search_Engine_Friendly_(SEF)_URLs
Verify .htaccess is Enabled
Check that your Apache config file allows .htaccess overrides. You must make sure overrides are enabled or the .htaccess file in your Joomla! root directory will be ignored or cause an error. In the section of your virtual host configuration file or in the main (httpd.conf) configuration file you must have something similar to the example below enabling overrides:
<Directory "/home/user/public_html">
AllowOverride All
</Directory>
<Directory "/path/to/htdocs">
AllowOverride All Options=[an option],[an option],...
</Directory>
There are other ways to test if .htaccess is enabled if you do not have access to your site's configuration files. Please refer to the .htaccess tutorial found on The Apache Software Foundation website for additional information.
Step by Step
These are step-by-step instructions. Please follow them in the order they are presented here. If a step fails, do not continue until you have solved the problem.
Rename the file "htaccess.txt" in your Joomla!'s base folder to ".htaccess".
This step may not be necessary. Open .htaccess in a text editor. Uncomment RewriteBase / (remove the first character, #). If Joomla is installed in its own folder, the enter the Joomla folder name after the backslash. e.g. RewriteBase /yourjoomlafolder.
Log on to your Back-end and open the Global Configuration.
Enable the Use Apache mod_rewrite/URL rewriting option and Save. This option uses the Apache mod_rewrite function to eliminate the "index.php" portion of the URL.
Check if your site works correctly. Your URLs should now look like:
http://www.example.com/the-­news/1­-latest-­news/1-­welcome-­to­-joomla
If this option causes errors, please see How to check if mod rewrite is enabled on your server.
If it is not enabled and you have access to the file apache/conf/httpd.conf, open that file and check if the line LoadModule rewrite_module modules/mod_rewrite.so is uncommented. If necessary, uncomment the line and restart the Apache web server.
If mod_rewrite cannot be enabled, leave this option off. It does not matter if you leave the .htaccess file renamed.
If you think this necessary, enable Add suffix to URLs and Save. This option adds .html to the end of URLs. There are different opinions on whether this is necessary or even useful. Search engines do not seem to care if your URLs end in .html or not.
Open the Plugin Manager and enable the System - SEF plugin. This plugin adds SEF support to links in your Joomla articles. It operates directly on the HTML and does not require a special tag.

Changing Apache directives on GoDaddy shared server

The site I'm working on is hosted on GoDaddy's shared servers. I need to increase the limit on the Apache directive LimitRequestBody. I've tried adding the following to .htaccess:
LimitRequestBody 20250000
But that doesn't have any effect. I've called GoDaddy support several times, and nobody there seems to know how to help.
Any ideas?
Make sure your .htaccess file is affecting the correct directory - the one where the script you want to limit lives. To affect only that directory, put your .htaccess file in the root directory(above your script) and wrap your directive with
<Directory "/var/www/path/to/script">
LimitRequestBody 20250000
</Directory>
After you change the .htaccess file, you need to run
# service httpd reload
I hope this helps.

Redirect HTML "/" to subfolder of WWW directory, the VirtualHost DocumentRoot

Sorry for asking this question again. Even though this has been asked and discussed quite a bit I cannot seem to find the right solution for a local dev environment using VirtualHost. I am using XAMPP Portable for Windows for dev work but assume this is the same for any other local server with regards to the .htaccess file.
DocumentRoot of VirtualHost is D:\dev\www\ for example.
ServerName is devwork.webdev for example.
HOSTS entry is 127.0.0.1 devwork.webdev.
VirtualHost file does have a default DocumentRoot being DocumentRoot "D:/xampp/htdocs". It works just fine.
The projects are each in a folder under D:\dev\www\ for example D:\dev\www\project01\ or D:\dev\www\project02\ and so on and show nicely in the browser when going to devwork.webdev with Options Indexes FollowSymLinks enabled. Apache is not showing any error and the access log file is also OK, things are working.
Now in my HTML when I use Project 01 a click on the link does link me to D:\dev\www\ showing all the projects I have in that folder.
Instead I would like to be linked to the root of the project, being D:\dev\www\project01\ or rather http://devwork.webdev/project01/.
How can I get that to work?
I am looking for a solution to this so that I can do dev work locally and without changing the HTML later FTP the data to the live host's root and it will work.
I have read and tried the following:
http://coolestguidesontheplanet.com/redirecting-a-web-folder-directory-to-another-in-htaccess/
https://perishablepress.com/redirect-subdirectory-to-root-via-htaccess/ .htaccess How to redirect root URL to subdirectory files, rewrite to clean URL AND not affect subdomains?
http://alexcican.com/post/how-to-remove-php-html-htm-extensions-with-htaccess/
https://stackoverflow.com/a/990405/1010918
How to redirect /directory/index.html and /directory/index.php to /directory/
Redirecting /directory/index.html to /directory/
with
How to remove .html from URL
and
http://forums.modx.com/thread/77211/endless-friendly-url-redirect-from-subdomain-folder-location
being closest to what I think I need but I must be doing something wrong since I always arrive at the DocumentRoot instead of the folder where the project is kept under the DocumentRoot.
Thank you for any help.
This seems closest:
Add VirtualHost definition for each project you want to access. (I'm
not sure how to do it on XAMPP for Windows).
For example, project01.devwork.webdev...
Set DocumentRoot for this VirtualHost to D:\dev\www\project01...
Add the hostname to your /etc/hosts/ file.
Open http://project01.devwork.webdev/ in your browser.
You should see the application in D:\dev\www\project01, while all URLs
will be based on "/".
What happens in the background:
When you open the URL http://project01.devwork.webdev/ in your browser, it will (as usual) translate it to IP address, but along with the request, it will also send Host header with the entered hostname:
GET / HTTP/1.1
Host: project01.devwork.webdev
Based on the Host field, Apache will decide which VirtualHost it needs to "pretend" to be, and serve files from the respective direcory.
However, if you need to have index of the projects, you will have to create it manually with full URLs.
An alternative with the given logic would be to simply add a VirtualHost for each project in D:dev\www\projectname by giving it its own domain instead of a subdomain on the host.
There is little difference there now when already editing httpd-vhosts.conf (using XAMP this file is in InstallDir and then in apache\conf\extra )but ideally it makes copying the local HTML to the live server without changing the HTML possible.
So this is something devs doing local work should keep in mind. I certainly will!! Thank you for your help and information.
<VirtualHost *:80>
DocumentRoot "D:/dev/www/newprojectname"
ServerName newdomainname.webdev
ServerAlias www.newdomainname.webdev
ErrorLog "D:/dev/www/log/dev-apache.error.log"
CustomLog "D:/dev/www/log/dev-apache.access.log" common
<Directory "D:/dev/www/newprojectname">
AllowOverride All
Options Indexes FollowSymLinks
Require local
# more detailed local
# Require ip 192.168.188
# or the IP from your local network
</Directory>
</VirtualHost>

How do I change the default index page in Apache?

I would like to change the default web page that shows up when I browse my site. I currently have a reporting program running, and it outputs a file called index.html. I cannot change what it calls the file. Therefore, my landing page must be called something else. Right now, when I browse my site it takes me to the reporting page.
From what I see, whatever you call index.html it will pull that up as your default. I want to change that to landing.html. How do I do this?
I am a folder (Folding # Home). The reporting program is HFM.net. HFM can output an html file with my current folding statistics. It names the html file index. I do not want that to be my default home page. I would like a menu-like landing where I can choose if I want to see my stats, or something else. The website is at /home/tyler/Documents/hfm/website (landing.html and hfm's index.html are here). Apache2 is in its default directory.
I'm also running Ubuntu 13.04.
I recommend using .htaccess. You only need to add:
DirectoryIndex home.php
or whatever page name you want to have for it.
EDIT: basic htaccess tutorial.
1) Create .htaccess file in the directory where you want to change the index file.
no extension
. in front, to ensure it is a "hidden" file
Enter the line above in there. There will likely be many, many other things you will add to this (AddTypes for webfonts / media files, caching for headers, gzip declaration for compression, etc.), but that one line declares your new "home" page.
2) Set server to allow reading of .htaccess files (may only be needed on your localhost, if your hosting servce defaults to allow it as most do)
Assuming you have access, go to your server's enabled site location. I run a Debian server for development, and the default site setup is at /etc/apache2/sites-available/default for Debian / Ubuntu. Not sure what server you run, but just search for "sites-available" and go into the "default" document. In there you will see an entry for Directory. Modify it to look like this:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
Then restart your apache server. Again, not sure about your server, but the command on Debian / Ubuntu is:
sudo service apache2 restart
Technically you only need to reload, but I restart just because I feel safer with a full refresh like that.
Once that is done, your site should be reading from your .htaccess file, and you should have a new default home page! A side note, if you have a sub-directory that runs a site (like an admin section or something) and you want to have a different "home page" for that directory, you can just plop another .htaccess file in that sub-site's root and it will overwrite the declaration in the parent.
You can also set DirectoryIndex in apache's httpd.conf file.
CentOS keeps this file in /etc/httpd/conf/httpd.conf
Debian: /etc/apache2/apache2.conf
Open the file in your text editor and find the line starting with DirectoryIndex
To load landing.html as a default (but index.html if that's not found) change this line to read:
DirectoryIndex landing.html index.html
I had a similar problem. When providing http://server/appDirectory I got a directory listing instead of index.html even though I had
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
in my httpd.conf file.
My solution was to uncomment the
LoadModule setenvif_module modules/mod_setenvif.so
line in httpd.conf
Apache version: 2.4
In Ubuntu you can add in file:
/etc/apache2/mods-enabled/dir.conf
line
DirectoryIndex myhomepage.htm
and then restart apache service
sudo systemctl restart apache2
In Unbuntu, you can update the default page on a site-by-site basis with the site config files eg:
/etc/apache2/sites-available/your.domain.conf
Same syntax for the key line in the file, eg mine is;
DirectoryIndex default.htm index.htm
Then don't forget to enable and reload:
sudo a2ensite your.domain.conf
sudo systemctl reload apache2