From 9ccbba14f109584381629a2a8ea88b47c0e9487b Mon Sep 17 00:00:00 2001 From: Andres Reyes Hernandez Date: Sat, 3 Jan 2026 01:44:34 -0700 Subject: [PATCH] redireccion basica --- .gitignore | 19 +++- README.md | 111 +--------------------- app/config/routes.php | 22 ++--- app/controllers/RedirectionController.php | 65 +++++++++++++ app/middlewares/DetectMobileDevice.php | 26 +++++ 5 files changed, 119 insertions(+), 124 deletions(-) create mode 100644 app/controllers/RedirectionController.php create mode 100644 app/middlewares/DetectMobileDevice.php diff --git a/.gitignore b/.gitignore index b9dbda1..c8f75b7 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,21 @@ vendor/ app/config/config.php composer.lock .vagrant/ -.runway-creds.json \ No newline at end of file +.runway-creds.json +.cursor/ +.gemini/ +.github/ +.windsurfrules +LICENSE +Vagrantfile +app/config/config_sample.php +app/log/ +docker-compose.yml +app/controllers/ApiExampleController.php +index-simple.php +runway +app/commands/SampleDatabaseCommand.php +app/views/welcome.php +README.md.old + + diff --git a/README.md b/README.md index f30d0be..d1845d8 100644 --- a/README.md +++ b/README.md @@ -1,110 +1,3 @@ -# Flight PHP Skeleton App +# Redirecciones de Ubicacion de Restaurantes -Use this skeleton application to quickly setup and start working on a new Flight PHP application. This application uses the latest version of Flight PHP v3. - -This skeleton is designed to be AI-friendly out of the box, with predefined instructions files for popular AI coding assistants such as GitHub Copilot, Cursor, and Windsurf. This helps streamline development and ensures your project is ready for modern, AI-assisted workflows. - -This skeleton application was built for Composer. You also could download a zip of this repo, downloading a zip of the [flightphp/core](https://github.com/flightphp/core) repo, and manually autoload the files by running `require('flight/autoload.php')` in your `app/config/# FlightPHP Skeleton Project Instructions - -This document provides guidelines and best practices for structuring and developing a project using the FlightPHP framework. - -## Installation - -Run this command from the directory in which you want to install your new Flight PHP application. (this will require PHP 7.4 or newer) - -```bash -composer create-project flightphp/skeleton cool-project-name -``` - -Replace `cool-project-name` with the desired directory name for your new application. - -After you create the project, make sure you go to the `app/config/config.php` and `app/config/services.php` and uncomment the lines related to the database you want to use before you get started. - -> _Tip: This skeleton includes configuration files for AI coding assistants (Copilot, Cursor, Windsurf) to help you get the most out of AI-driven development tools from the start._ - -### Robust Setup of the Application - -This skeleton will come with 2 versions of a starter application. The robust version is a fully structured application meant for projects that you anticipate will be a bigger size. This is setup with object oriented programming in mind so that it is easier to unit test and scale your project with multiple developers (or make it easier on yourself). - -The robust version adds an `app/` directory where everything has a basic structure. This is how this skeleton is configured by default.meant - -### Simple Setup of the Application - -This is basically a single file application. The only exception to this is the config file which is still in the `app/config/` directory. This is a good starting point for smaller projects or projects that you don't anticipate will grow much. - -To use the simple version, you'll need to move the `index-simple.php` file to the `public/` directory and rename it to `index.php`. You can delete any other controllers, views, or config files (except the `config.php` file of course). - -With the simple setup, there is two very import security steps to be aware of. -- **DO NOT SAVE SENSITIVE CREDENTIALS TO THE `index.php` FILE**. -- **DO NOT COMMIT ANY TYPE OF SENSITIVE CREDENTIALS TO YOUR REPOSITORY**. - -This is what the config file is for. If you need to save sensitive credentials, save them to the config file and then reference them in the `index.php` file. - -## Running the Application - -### No Dependency Setup - -To run the application in development, you can run these commands - -```bash -cd cool-project-name -composer start -``` - -After that, open `http://localhost:8000` in your browser. - -__Note: If you run into an error similar to this `Failed to listen on localhost:8000 (reason: Address already in use)` then you'll need to change the port that the application is running on. You can do this by editing the `composer.json` file and changing the port in the `scripts.start` key.__ - -### Docker Setup - -You can [install Docker](https://docs.docker.com/engine/install/) and use `docker-compose` to run the app with `docker`, so you can run these commands: -```bash -cd cool-project-name -docker-compose up -d -# or if a newer version of docker -docker compose up -d -``` -After that, open `http://localhost:8000` in your browser. - -### Vagrant Setup -You can [install Vagrant](https://vagrantup.com/download) and a provider like [VirtualBox](https://www.virtualbox.org/wiki/Downloads) and use simple run the following command to bring up an environment with PHP/MariaDB already setup based on [n0nag0n/firefly](https://github.com/n0nag0n/firefly) - -```bash -cd cool-project-name -vagrant up -``` - -After that, open `http://localhost:8000` in your browser. - -## Project Structure - -This skeleton is organized for clarity and maintainability, and is also structured to be easily navigable by AI coding assistants. The following layout is recommended: - -``` -project-root/ -│ -├── app/ # Application-specific code -│ ├── controllers/ # Route controllers (e.g., HomeController.php) -│ ├── middlewares/ # Custom middleware classes/functions -│ ├── models/ # Data models (if needed) -│ ├── utils/ # Utility/helper functions -│ ├── views/ # View templates (if using) -│ └── commands/ # Custom CLI commands for Runway -│ -├── public/ # Web root (index.php, assets, etc.) -│ -├── config/ # Configuration files (database, app settings, routes) -│ -├── vendor/ # Composer dependencies -│ -├── tests/ # Unit and integration tests -│ -├── composer.json # Composer config -│ -└── README.md # Project overview -``` - -> _Predefined instructions for AI tools are included in this skeleton, making it easier for AI assistants to understand and help you with this structure._ - -## Do it! -That's it! Go build something flipping sweet! +Permite redireccionar las rutas de la aplicación a las aplicaciones de Ubicacion de Restaurantes de Apple y Google. \ No newline at end of file diff --git a/app/config/routes.php b/app/config/routes.php index 1a5988b..432208f 100644 --- a/app/config/routes.php +++ b/app/config/routes.php @@ -1,12 +1,14 @@ group('', function(Router $router) use ($app) { $router->get('/', function() use ($app) { - $app->render('welcome', [ 'message' => 'You are gonna do great things!' ]); - }); + $app->redirect('https://google.com/maps'); + } ); - $router->get('/hello-world/@name', function($name) { - echo '

Hello world! Oh hey '.$name.'!

'; - }); + $router->get('/@path', [ RedirectionController::class, 'redirect' ] ); - $router->group('/api', function() use ($router) { - $router->get('/users', [ ApiExampleController::class, 'getUsers' ]); - $router->get('/users/@id:[0-9]', [ ApiExampleController::class, 'getUser' ]); - $router->post('/users/@id:[0-9]', [ ApiExampleController::class, 'updateUser' ]); - }); - -}, [ SecurityHeadersMiddleware::class ]); \ No newline at end of file +}, [ SecurityHeadersMiddleware::class, DetectMobileDevice::class ]); \ No newline at end of file diff --git a/app/controllers/RedirectionController.php b/app/controllers/RedirectionController.php new file mode 100644 index 0000000..a1a3d31 --- /dev/null +++ b/app/controllers/RedirectionController.php @@ -0,0 +1,65 @@ +app = $app; + } + + public function redirect( string $path) + { + $data = $this->getRedirections(); + $path_lower = strtolower($path); + + if (array_key_exists($path_lower, $data)) { + $data = $data[$path_lower]; + $website = $this->app->get('is_apple') ? $data['website1'] : $data['website2']; + + if (!empty($website)) { + $this->app->redirect($website); + return; + } + } + + //Fallback if path not found or website1 is empty + $this->app->redirect('https://google.com/maps'); + } + + public function getRedirections() { + + $data = [ + 'malecon' => [ + 'website1' => 'https://maps.apple/p/-ezVTdQ8aSUs.n', + 'website2' => 'https://maps.app.goo.gl/n1betgNTZgx4RoEJ8' + ], + 'puntacerritos' => [ + 'website1' => '', + 'website2' => 'https://maps.app.goo.gl/NSDoQZXnFWDcEgor5' + ], + 'zonadorada' => [ + 'website1' => '', + 'website2' => 'https://maps.app.goo.gl/CDt7vRw2M6oEqgBA8' + ], + 'galeron' => [ + 'website1' => '', + 'website2' => 'https://maps.app.goo.gl/CjkXvvNd2aA4ftiKA' + ], + 'monosbichis' => [ + 'website1' => '', + 'website2' => 'https://maps.app.goo.gl/M1dHZoRANfgCH9f67' + ], + 'pinchisplebes' => [ + 'website1' => '', + 'website2' => 'https://maps.app.goo.gl/o2uq6qQQiLxAkw7f6' + ] + ]; + + return $data; + } +} \ No newline at end of file diff --git a/app/middlewares/DetectMobileDevice.php b/app/middlewares/DetectMobileDevice.php new file mode 100644 index 0000000..16264d9 --- /dev/null +++ b/app/middlewares/DetectMobileDevice.php @@ -0,0 +1,26 @@ +app = $app; + } + + public function before(array $params): void + { + $userAgent = $this->app->request()->user_agent; + + $is_apple = preg_match('/iPhone|iPad|iPod/i', $userAgent); + + $this->app->set('is_apple', $is_apple); + } +} \ No newline at end of file