Problems configuring Mercury

Responder
karweru
Mensajes: 3
Registered for: 3 years 5 months
Kenya

Problems configuring Mercury

Mensaje por karweru »

Hi All,

For starters, Im a newbie in web programming and currently studying html & css which I believe will help me understand mod_harbour better.

I already installed xampp & mod_harbour on my windows 10 pc and I'm able to run samples by simply typing on the browser //localhost/samples/test.prg

I've installed Mercury as follows in c:\xampp\htdocs\master\mercury

Specifically, I'm lost at step 2.- Setting up our .htaccess file in the instruction manual. Is this step referring to the c:\xampp\htdocs\master\mercury\.htaccess file and should I overwrite the contents with:
Spoiler
SetEnv PATH_URL "/hweb/apps/minimvc"
SetEnv PATH_APP "/hweb/apps/minimvc"
SetEnv PATH_DATA "/hweb/apps/minimvc/data/"

# --------------------------------------------------------------------------
# CONFIGURATION PATH APPLICATION (Relative to DOCUMENT_ROOT)
# --------------------------------------------------------------------------
SetEnv PATH_URL "/hweb/apps/minimvc"
SetEnv PATH_APP "/hweb/apps/minimvc"
SetEnv PATH_DATA "/hweb/apps/minimvc/data/"
Currently, the .htaccess file contains:
Spoiler
# --------------------------------------------------------------------------
# CONFIGURACION RUTAS PROGRAMA (Relative to DOCUMENT_ROOT)
# --------------------------------------------------------------------------
SetEnv APP_TITLE "Mercury v1.0"

SetEnv PATH_URL "/master/mercury"
SetEnv PATH_APP "/master/mercury"
SetEnv PATH_DATA "/master/mercury/data/"

SetEnv PATH_MERCURY "/master/mercury/lib/mercury"

# --------------------------------------------------------------------------
# Impedir que lean los ficheros del directorio
# --------------------------------------------------------------------------
Options All -Indexes

# --------------------------------------------------------------------------
# Pagina por defectos
# --------------------------------------------------------------------------
DirectoryIndex index.prg main.prg

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.prg/$1 [L]
</IfModule>

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.prg/$1 [L]
</IfModule>


<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.prg/$1 [L]
</IfModule>
Also, how can I get to test (and learn) samples in c:\xampp\htdocs\master\mercury\examples folder?

Avatar de Usuario
ricardo arraes
Mensajes: 87
Registered for: 3 years 5 months
Brazil

Mensaje por ricardo arraes »

Hey Karweru, how you doing?

So let's make sure that everything is well understood...

*.Htaccess is a file that contains some environment variables and (standard) settings from your web application.

*If you are using Windows Environment:
In every single web application directory there'll be a .htaccess file that will be related to the web application.

For example:

I got 2 web applications hosted in my server like that:

/xampp/htdocs/app1
/xampp/htdocs/app2

There'll be a .htaccess inside each one of these directories and theses .htaccess file will be responsible for the settings of it's application. Ok?

*If you are using Linux Environment:
There's no need to create many .htaccess files, instead, the settings of all your applications will be located in the /etc/apache/apache2.conf file.


Now, about the examples...

all you gotta do is create a directory inside /xampp/htdocs like: /xampp/htdocs/go

copy all the paths and files inside /mercury/examples and paste it inside the directory you just created.

(Or you can simply copy the whole examples folder and paste it inside /xampp/htdocs directory)

Hope it helps you!
The work always comes before the belief

Avatar de Usuario
ricardo arraes
Mensajes: 87
Registered for: 3 years 5 months
Brazil

Mensaje por ricardo arraes »

By the way Karweru,

if you are interested in learning more about Mod_harbour and Mercury, I launched a Online Course explaining the basics and some good practices.
You can find it here:

https://go.hotmart.com/K39741308S?dp=1

:D
The work always comes before the belief

karweru
Mensajes: 3
Registered for: 3 years 5 months
Kenya

Mensaje por karweru »

Thank you Ricardo for the clarification,

I have created a folder c:\xampp\htdocs\app1 and copied .htaccess to it and the version.prg file.

When is type //localhost/app1/version.prg, i get the following result.

Error: Unknown or unregistered symbol
operation: APP
called from: HB_HRBLOAD, line: 0
called from: ..\apache.prg, EXECUTE, line: 143

Source:

I trust I'll join your training program once I can at least get the basics running so that I have a clear understanding of what Im getting into. I have a lot of code written in HMG (Harbour minigui for Windows) that I need to transform to the web.

Once again, thank you very much.

Avatar de Usuario
ricardo arraes
Mensajes: 87
Registered for: 3 years 5 months
Brazil

Mensaje por ricardo arraes »

Ok, great! Now you got the directory right where it belongs...

But first you gotta understand that when you are using ModHarbour and Mercury to develop your application, you are applying the MVC architeture to your project. One of the main concepts of the MVC pattern is that your application needs a single entry point, which means that every request made by your client will get to your application through a unique "door".

In your .htaccess file is where you define this "door". if you open the file, you'll see that there's a line just like this one:

Código: Seleccionar todo

DirectoryIndex index.prg main.prg
This line right here is defining the your index.prg file as the entry point (the "door") of your application. ok? And inside this index.prg there'll be the router of your application.

the router is like a map, there'll be the valid routes (valid URLs) of your application and the router in charge of redirecting your requests to their right way inside your application.

So, after this brief explanation, what I mean is that now there's no need to call for a prg file like that:

Código: Seleccionar todo

/localhost/app1/version.prg
if the version.prg is a controller (remember, we are applying the MVC concept), all you gotta do is define a route to it and call for the URL in the browser.

I suggest you to open the index.prg file inside your directory to understand what I just said... and, at the browser, call for:

Código: Seleccionar todo

/localhost/app1

***remember that you before theses steps you gotta configure the .htaccess file to the new directory, for example:

BEFORE

Código: Seleccionar todo

SetEnv APP_TITLE           "Mercury v1.0"
SetEnv PATH_URL            "/master/mercury/examples"
SetEnv PATH_APP            "/master/mercury/examples"
SetEnv PATH_DATA           "/master/mercury/examples/data/"
AFTER

Código: Seleccionar todo

SetEnv APP_TITLE           "Mercury v1.0"
SetEnv PATH_URL            "/app1"
SetEnv PATH_APP            "/app1"
SetEnv PATH_DATA           "/app1/data/"
The work always comes before the belief

karweru
Mensajes: 3
Registered for: 3 years 5 months
Kenya

Mensaje por karweru »

Thank you very much Ricardo for your patience and guidance....you are a good teacher. I will now continue with the rest of the manual and hope to join you soon in your classes.
mercury.png
Many thanks.
No tiene los permisos requeridos para ver los archivos adjuntos a este mensaje.

Avatar de Usuario
ricardo arraes
Mensajes: 87
Registered for: 3 years 5 months
Brazil

Mensaje por ricardo arraes »

No problem Karweru, you're welcome, I'm glad that it helped you! :)

Don't forget that, for every application you develop, you need to configure the .htaccess accordingly to the directory so mod_harbour and mercury can find the lib and include files.
The work always comes before the belief

Responder