{"id":22927050,"url":"https://github.com/ubul86/szallas_hu_test","last_synced_at":"2026-04-07T08:01:41.480Z","repository":{"id":266816409,"uuid":"894016946","full_name":"ubul86/szallas_hu_test","owner":"ubul86","description":"Szallas.hu Backend Developer Test Application - A Laravel 10-based test REST API project with Dockerized services (PHP, MySQL, Nginx, Node.js) and optional CLI commands for data management. Includes setup instructions for Docker and non-Docker environments, testing tools like PHPUnit and PHPStan, and CSV-based database seeding.","archived":false,"fork":false,"pushed_at":"2025-02-15T09:21:08.000Z","size":1136,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-25T14:51:27.193Z","etag":null,"topics":["docker","docker-compose","elasticsearch","laravel","mysql","php8","phpunit","repository-pattern","rest-api","solid-principles","static-analysis"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ubul86.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-11-25T15:51:55.000Z","updated_at":"2025-02-15T09:21:12.000Z","dependencies_parsed_at":"2025-01-27T07:22:36.064Z","dependency_job_id":"de45fc27-0b5a-48bc-b1f0-290e5f04dd91","html_url":"https://github.com/ubul86/szallas_hu_test","commit_stats":null,"previous_names":["ubul86/szallas_hu_test"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ubul86/szallas_hu_test","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ubul86%2Fszallas_hu_test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ubul86%2Fszallas_hu_test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ubul86%2Fszallas_hu_test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ubul86%2Fszallas_hu_test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ubul86","download_url":"https://codeload.github.com/ubul86/szallas_hu_test/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ubul86%2Fszallas_hu_test/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31504897,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T03:10:19.677Z","status":"ssl_error","status_checked_at":"2026-04-07T03:10:13.982Z","response_time":105,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-compose","elasticsearch","laravel","mysql","php8","phpunit","repository-pattern","rest-api","solid-principles","static-analysis"],"created_at":"2024-12-14T09:12:58.146Z","updated_at":"2026-04-07T08:01:41.462Z","avatar_url":"https://github.com/ubul86.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Szallas.hu Test Rest API application\n\n# Table of Contents\n\n- [Minimum Requirements](#minimum-requirements)\n- [Docker Services](#docker-services)\n- [Installation With Docker](#installation-with-docker)    \n- [Installation Without Docker](#installation-without-docker)\n- [API Endpoints](#api-endpoints)\n- [Optional CLI Commands](#optional-cli-commands)    \n- [Testing and Analysis Tools](#testing-and-analysis-tools)    \n- [Running Tests](#running-tests)    \n- [Docker Installation](#docker-installation)    \n- [Docker Compose Installation](#docker-compose-installation)\n- [Example Images](#example-images)\n\n## Minimum Requirements\n\n- **Docker and Docker Compose**\n\n**...or without Docker:**\n\n- **PHP**: 8.2 or higher\n- **Composer**: 2.0 or higher\n- **MySQL**: 5.7 or higher\n- **Laravel**: 10.x\n- **Node.js 20** or higher\n\n## Docker Services\n\nThis project uses Docker to containerize the different components of the application. Below is a description of each service defined in the `docker-compose.yml` file:\n\n- **nginx**: The Nginx service serves as a reverse proxy for the application, routing HTTP requests to the appropriate backend services.\n\n- **php**: This service runs the PHP application (Laravel) using PHP 8.1. It is the core backend service that handles HTTP requests, interacts with the database, and manages the application logic. The service shares the application codebase with the host machine to enable hot-reloading during development.\n\n- **mysql**: This service runs the MySQL database server, which stores the application's data. The database is configured with persistent storage to retain data across container restarts. The database credentials and other environment variables are defined in the `.env` file.\n\n- **phpmyadmin**: A web-based interface for managing MySQL databases. It allows developers to interact with the database, run queries, and manage tables via a user-friendly UI. The service is accessible via a browser on port 80 (or a custom port defined in the `.env` file).\n\n- **node**: This service is responsible for building and serving the Vue.js frontend application. It runs the Node.js server, compiles assets, and serves the frontend during development.\n\n- **php-cli-cron**: A dedicated service for running scheduled cron jobs. This service is built from the `Dockerfile_php_cron` file located in the `docker_settings` directory. It mounts the application code and configuration files from the host machine, ensuring that any changes are reflected in the container. This service depends on the `php` service and uses the shared application codebase.\n\n- **elasticsearch**: This service provides a search engine for the application, enabling efficient and scalable full-text search capabilities. It uses the `docker.elastic.co/elasticsearch/elasticsearch:8.10.1` image and runs as a single-node instance. Persistent data storage ensures that search indexes are retained across container restarts. The service is secured with an environment variable-defined password (`ELASTICSEARCH_PASS`) and is accessible on port `9200`. Memory usage is configured to optimize performance.\n\n\n## Installation With Docker\n\nFirst, need a fresh installation of Docker and Docker Compose\n\n### 1. Clone the Project\n\nClone the repository to your local machine:\n\n```bash\ngit clone https://github.com/ubul86/szallas_hu_test.git\ncd szallas_hu_test\n```\n\n### 2. Copy Environment File\n\nCopy the .env.example file to .env\n\n```bash\ncp .env.example .env\n```\n\nCopy the .env.testing.example file to .env.testing\n```bash\ncp .env.testing.example .env.testing\n```\n\n### 3. Set Environment Variables\nIn the .env file, you need to set the DB connections and some Host and Elasticsearch params.\nHere is an example configuration:\n\n```env\nDB_CONNECTION=mysql\nDB_HOST=mysql82\nDB_PORT=3306\nDB_DATABASE=your_database_name # for example szallashu_test\nDB_USERNAME=your_database_username # for example szallashu\nDB_PASSWORD=your_database_password # for example szallashu\nDB_ROOT_PASSWORD=your_database_root_password # for example szallashuadmin\n\nNGINX_PORT=8080\nPHPMYADMIN_PORT=45678\n\n...\n\nELASTICSEARCH_HOST=elasticsearch:9200\nELASTICSEARCH_USER=elastic\nELASTICSEARCH_PASS=elastic\n\n```\n\nThe DB_HOST needs to be mysql82 service name.\n\n### 4. Build The Containers\n\nGo to the project root directory, where is the docker-compose.yml file and add the following command:\n\n```bash\ndocker-compose up -d --build\n```\n\n### 5. Install Dependencies:\n\nInstall PHP dependencies using Composer:\n\n```bash\ndocker exec -it {php_fpm_container_name} composer install\n```\n\nor\n```bash\ndocker exec -it {php_fpm_container_name} bash\ncomposer install\n```\n\n### 6. Generate Application Key\n\n```bash\ndocker exec -it {php_fpm_container_name} php artisan key:generate\n```\n\nor\n```bash\ndocker exec -it {php_fpm_container_name} bash\nphp artisan key:generate\n```\n\n\n### 7. Run Migrations\n\nRun the database migrations with seed:\n\n```bash\ndocker exec -it {php_fpm_container_name} php artisan migrate:fresh\n```\n\nor\n\n```bash\ndocker exec -it {php_fpm_container_name} bash\nphp artisan migrate:fresh\n```\n\n### 8. Install Npm Packages\n\n\n```bash\ndocker exec -it {node_container_name} npm install\n```\n\nor\n\n```bash\ndocker exec -it {node_container_name} npm install\n```\n\n### 10. Migrate datas from the given csv\n\n```bash\ndocker exec -it {php_fpm_container_name} php artisan import:csv\n```\n\n### 10. (Optional) Change User and Group in php container\n\nYou may need to change the user and group inside the PHP container if you encounter an error. Unfortunately, this is a known issue when using the application with Docker.\n\n```bash\ndocker exec -it {php_container} chown -R www-data:www-data *\n```\n\n## Installation Without Docker\n\n### 1. Clone the Project\n\nClone the repository to your local machine:\n\n```bash\ngit clone https://github.com/yourusername/your-repository.git\ncd your-repository\n```\n\n### 2. Install Dependencies\n\nInstall PHP dependencies using Composer:\n\n```bash\ncomposer install\n```\n\n### 3. Copy Environments File\n\nCopy the .env.example file to .env\n\n```bash\ncp .env.example .env\n```\n\nCopy the .env.testing.example file to .env.testing\n\n```bash\ncp .env.testing.example .env.testing\n```\n\n### 5. Configure the Database\n\nCreate a new database for the project and set the database connection in the .env file. Update the following lines in your .env file. There is an example setting:\n\n```env\nDB_CONNECTION=mysql\nDB_HOST=127.0.0.1\nDB_PORT=3306\nDB_DATABASE=your_database_name\nDB_USERNAME=your_database_username\nDB_PASSWORD=your_database_password\n```\n\n### 6. Run Migrations\n\nRun the database migrations:\n\n```bash\nphp artisan migrate\n```\n\n### 7. Import the data from the given csv\n\nSeed the database with from csv data:\n\n```bash\nphp artisan import:csv\n```\n\n### 8. Install Npm Packages\n\n```bash\nnpm install\n```\n\n### 9. Start the Development Server\n\nRun the Laravel development server:\n\n```bash\nphp artisan serve\n```\n\nThe application should now be accessible at http://localhost:8000.\n\n## API Endpoints\n\nDetailed information about the available API endpoints can be found in the [API_ENDPOINTS.md](./API_ENDPOINTS.md) file.\n\n\n## Optional CLI Commands\n\nThe project includes several optional CLI commands to manage and process company data. These commands can be executed via `php artisan`.\n\n---\n\n### 1. Import Companies from CSV\n\n**Command:**  \n`php artisan import:csv`\n\n**Description:**  \nImports companies along with their associated addresses, owners, and employees based on the `employees` field in the CSV file.\n\n---\n\n### 2. Foundation Date Paginator\n\n**Command:**  \n`php artisan company:foundation-date-paginator [--page] [--date-start] [--date-end] [--per-page]`\n\n**Description:**  \nDisplays all dates since `2001-01-01` with two columns:\n- The first column lists the date.\n- The second column lists the company name if a company was founded on that day, otherwise remains empty.\n\n**Parameters:**\n\n\n| **Name**     | **Required** | **Type** | **Description**                                                 |\n|--------------|--------------|----------|-----------------------------------------------------------------|\n| `page`       | Optional     | integer  | Specifies the page number to list, starting from 1. If not provided, the first page is shown by default.           |\n| `per-page`   | Optional     | Integer  | The number of records to return per page. Defaults to 50 if not provided.|\n| `date-start` | Optional     | date     | The start date for the date range. Defaults to 2001-01-01 if not provided.                      |\n| `date-end`   | Optional     | date     | The end date for the date range. If not provided, the query will use the current date as the end date.\n\n\n---\n\n### 3. Foundation Date Paginator with Recursive CTE\n\n**Command:**  \n`php artisan company:foundation-date-paginator-with-recursive-cte [--page]`\n\n**Description:**  \nSimilar to the `foundation-date-paginator` command but uses a **recursive CTE** (Common Table Expression) to calculate the results.\nWhen using this command, ensure that `cte_max_recursion_depth` is set to a sufficiently high value in the database configuration. Note: This is not necessary in a **Docker** environment, as it is already configured automatically\n\n---\n\n### 4. Generate Pivot Table of Companies by Activity\n\n**Command:**  \n`php artisan company:generate-pivot-companies`\n\n**Description:**  \nGenerates an aggregated table where:\n- **Columns** dynamically represent values from the `activity` field of the `companies` table.\n- **Rows** contain the names of companies associated with each activity.\n\nThe command invokes and executes a predefined **stored procedure** created through a migration.\n\n---\n\n### Notes\n\n- Ensure the database configurations are properly set for commands involving **CTEs** or **stored procedures**.\n\n## Testing and Analysis Tools\n\n### PHP CodeSniffer (PHPCS)\n\nPHPCS is used to check coding standards and style violations.\n\n```bash\ncomposer lint\n```\n\nor\n\n```bash\ndocker exec -it {php_fpm_container} composer lint\n```\n\n### PHPStan\n\nPHPStan is used for static code analysis to find bugs and improve code quality.\n\nRun PHPStan:\n\n```bash\ncomposer analyse\n```\n\nor\n\n```bash\ndocker exec -it {php_fpm_container} composer analyse\n```\n\nNote: You might need to update your phpstan.neon configuration if you encounter issues or deprecations.\n\n### PHPUnit Coverage XML to SonarQube\n\nTo generate code coverage data and send it to SonarQube, run the PHPUnit tests with coverage enabled and specify the output file for the coverage report:\n\n```bash\nphp artisan test --coverage-clover=tests/_output/coverage.xml\n```\n\n### SonarQube\n\n1. **Login to SonarQube:**\n\n    Access SonarQube at the following address: http://sonarqube:9000. The default login credentials are:\n\n    Username: admin\n    Password: admin\n\n2. **Create a New Project:**\n\n   After logging in, click on Create Project. \n   Follow the steps to create a new project by naming it and setting up the necessary parameters.\n   \n3. **Generate a Token:**\n\n    Once the project is created, go to My Account \u003e Security.\n    Under the Tokens section, generate a new token and save it. You will use this token for authentication when running SonarScanner.\n\n### Sonar Scanner Client\n\nTo run SonarQube analysis using the SonarScanner client, follow these steps:\n\n#### With Docker:\n\n1. Run the docker-compose command\n   ```bash\n   docker-compose run sonar-scanner\n   ```\n   \n#### Without Docker:\n\n1. Install SonarScanner:\n\n    Install the SonarScanner on your local machine or CI/CD pipeline environment. Follow the installation guide on the official SonarScanner website.\n\n2. Run the Scanner:\n\n    Once SonarScanner is installed and configured, navigate to the project directory and run the following command, replacing YOUR_SONARQUBE_TOKEN with the token generated earlier:\n\n    ```bash\n    sonar-scanner \\\n    -Dsonar.projectKey=your_project_key \\\n    -Dsonar.sources=. \\\n    -Dsonar.host.url=http://sonarqube:9000 \\\n    -Dsonar.login=YOUR_SONARQUBE_TOKEN\n    ```\n    This will send the code analysis results to SonarQube.\n\n\n## Running Tests\n\n### PHPUnit\n\nUnit tests are written using PHPUnit. To run tests, first configure the .env.testing file\n\nRun the tests:\n\n```bash\nphp artisan test\n```\n\nor\n\n```bash\ndocker exec -it {php_fpm_container} php artisan test\n```\n\n\nThis will execute all tests in the tests directory and provide a summary of test results.\n\n## Docker Installation\n\n### Linux\n\n- Ubuntu: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-20-04\n- For Linux Mint: https://computingforgeeks.com/install-docker-and-docker-compose-on-linux-mint-19/\n\n### Windows\n\n- https://docs.docker.com/desktop/windows/install/\n\n## Docker Compose Installation\n\n### Linux\n\nhttps://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-compose-on-ubuntu-20-04\n\n### Windows\n- Docker automatically installs Docker Compose.\n\n## Example Images\n\n![List Companies](documents/sample_images/company_list.png )\n![List Companies Mobile](documents/sample_images/company_list_mobile.png )\n![Edit Company](documents/sample_images/edit_company.png )\n![View Company Details](documents/sample_images/view_company_details.png )\n![Company Foundation Date Result](documents/sample_images/company_foundation_date_result.png )\n![Pivot Table Result](documents/sample_images/pivot_table_result.png )\n![PHPStan Result](documents/sample_images/phpstan_result.png )\n![SonarQube Result](documents/sample_images/sonarqube_result.png )\n![PHPMetrics Result](documents/sample_images/phpmetrics_result.png )\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fubul86%2Fszallas_hu_test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fubul86%2Fszallas_hu_test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fubul86%2Fszallas_hu_test/lists"}