[Tutorials] PHP Simple Framework v0.2 - [01] Starting a Project
🌐 This is an automatic translation of a topic from Underc0de, the largest Spanish-speaking hacking and IT community. Read the original (Spanish) and reply →
kid_goth ·
Good afternoon/evening/morning,<br /><br />In this topic I'm going to start publishing the tutorials for the framework already mentioned in another post (https://underc0de.org/foro/php/php-simple-framework-v0-2/). The idea is that whenever I can, I'll publish them all in this same thread (as replies), changing only the title so as not to create so many topics. I also publish them on my blog in case you'd like to stop by, but it's not necessary, I paste here exactly what I publish there hehe. So let's begin:<br /><br />
<br /><br />We're starting the PHP Simple Framework tutorials. In this tutorial, we're going to learn how to install the project and set up the initial configuration so we can then continue with our application.<br /><br />I'm going to use a lot of gifs (well, or regular images hehehe) to show the steps to follow in a more understandable way, since recording bores me D:<br /><br />So let's get started:<br />First of all, I'm sure you already have your web server configured, whether on gnu/linux, windows or mac (bsd, sun, etc.), so I won't go into detail on that. Start your services please (in your wampp, xampp, mampp, with your console sudo service or however it's done on your operating system).<br /><br />Once started, we have 3 options:<br /><br />1. Download the repository zip file.<br /><br />For this you must go to the following URL Los enlaces son solo para miembros. Registrate o iniciá sesión and download either the ZIP or TAR.GZ file of v0.2.<br /><br />Then, you create the destination directory for your application and extract the file there.<br /><br />2. Via git, from the terminal simply type:<br /><br />Código: bash
<br /><br />3. If you have composer installed, then you create the project like this:<br /><br />Código: bash
$ composer create-project grafikamos/phpsfw
<br /><br />Our next step is even simpler: we open the configuración.json file with whatever editor we like and set the necessary parameters for the app.<br /><br />
<br /><br />Among them, the important ones are sitio, psfw and bd... for a more detailed description refer to the framework's README.md (Los enlaces son solo para miembros. Registrate o iniciá sesión<br /><br />We save the file and, again from the terminal, run composer install. Located in the project directory, we run the following command (don't worry if you don't have composer installed, the framework ships with a copy of it to avoid these problems):<br /><br />Código: bash
<br /><br />Finally, to see the project running with the users demo, we load the database called test.sql with your preferred database manager, whether phpmyadmin, the terminal, navicat, mysql workbench, etc. Remember that the bd parameters must be configured correctly for everything to work as it should.<br /><br />And all that's left is to create the views cache directory; it must be the same one set in the configuration (configuracion.json) under psfw->dir_cache. In my case cache/raintpl/, so we run these 2 commands:<br /><br />Código: bash
$ mkdir cache/raintpl<br />$ chmod 777 -R cache
<br /><br />The second one is for permissions; on windows this last one is probably not necessary, and instead of mkdir use md.<br /><br />Note: If you are a windows user, you must perform this step for it to work correctly. The error comes from the use of DIRECTORY_SEPARATOR in the RainTPL library, since they haven't fixed it in the latest stable version (3.1.0), which is the one we currently use, so we're going to fix it manually.<br /><br />So let's open the following file: extras/rain/raintpl/library/Rain/Tpl.php and at line 241 (the line may vary; to be sure, look for the function called checkTemplate) change the following line:<br /><br />this:<br /><br />Código: php
<br /><br />Then we go to this file: extras/rain/raintpl/library/Rain/Tpl/Parser.php and at line 663 (or, in case it changes, in the reducePath function, which is currently the last function in the file), we change the following:<br /><br />This:<br /><br />Código: php
<br /><br />or if you prefer, just delete it. It may be that in the future, after this post is published, these steps won't be necessary, since the pull request with the fix has already been sent and it's just waiting to be added to the release. So if you don't see those lines exactly as I mention them, don't touch anything hehehe.<br /><br />And that's it, we can see our project on the web:<br /><br />
<br /><br />If any problem occurs, don't hesitate to write it in the comments, and also set debug to 1 in the configuration to see what problems came up.<br /><br />I'll stay tuned, and thank you very much for reading. Regards, kid_goth.
arthusu ·
Not bad, dude! I'm saving it to read later! :) +1
DuendeSlayeR ·
Interesting info, thanks for the contribution.<br /><br />Regards