{"id":16233310,"url":"https://github.com/msalsas/symfony-bundle-skeleton","last_synced_at":"2025-03-19T14:31:29.196Z","repository":{"id":39256027,"uuid":"235431117","full_name":"msalsas/symfony-bundle-skeleton","owner":"msalsas","description":"The \"Symfony Bundle Skeleton\" is an application to create reusable Symfony bundles.","archived":false,"fork":false,"pushed_at":"2023-01-24T08:55:23.000Z","size":14126,"stargazers_count":9,"open_issues_count":22,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-28T19:20:53.964Z","etag":null,"topics":["php","reusable-symfony-bundles","symfony","symfony-bundle","symfony-bundle-skeleton"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/msalsas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-21T20:05:01.000Z","updated_at":"2024-07-30T21:34:37.000Z","dependencies_parsed_at":"2023-02-13T19:30:46.312Z","dependency_job_id":null,"html_url":"https://github.com/msalsas/symfony-bundle-skeleton","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msalsas%2Fsymfony-bundle-skeleton","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msalsas%2Fsymfony-bundle-skeleton/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msalsas%2Fsymfony-bundle-skeleton/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msalsas%2Fsymfony-bundle-skeleton/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/msalsas","download_url":"https://codeload.github.com/msalsas/symfony-bundle-skeleton/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243997108,"owners_count":20380980,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["php","reusable-symfony-bundles","symfony","symfony-bundle","symfony-bundle-skeleton"],"created_at":"2024-10-10T13:12:11.576Z","updated_at":"2025-03-19T14:31:28.508Z","avatar_url":"https://github.com/msalsas.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Symfony Bundle Skeleton\n========================\n\nThe \"Symfony Bundle Skeleton\" is an application for creating reusable Symfony bundles.\nForked from [symfony/demo][1]\n\nRequirements\n------------\n\n  * PHP 7.4 or higher;\n  * PDO-SQLite PHP extension enabled;\n  * and the [usual Symfony application requirements][2].\n\nInstallation\n------------\n\n```bash\n$ git clone https://github.com/msalsas/symfony-bundle-skeleton.git\n```\n\nInstall Composer dependencies:\n\n```bash\n$ composer install\n```\n\nUsage\n-----\n\nRun this command to create the new bundle in `/lib`:\n\n```bash\n$ php bin/console skeleton-bundle:create\n```\n\nYou will be asked for some needed arguments for the bundle structure and files.\n\nThen, just cd to the new created bundle:\n\n```bash\n$ cd lib/your-namespace # E.g. cd lib/acme/foo-bundle\n```\nAnd check your already created git repository:\n\n```bash\n$ git status\n```\nNow you can begin to develop over this path (your bundle path).\nCheck for the TODO's comments in all files and make the needed changes for your bundle.\n\nThere is just one file you have to edit outside your bundle path: \n\n`config/packages/{your-bundle}.yaml`\n\nThis file includes your bundle configuration.\n\nOnce your ready, create a new repository (Github or whatever) and add the remote url to your git config:\n\n```bash\n$ git add .\n$ git commit -m \"First commit\"\n$ git remote add origin your-repository-url.git\n$ git push -u origin master\n```\n\nThere's no need to configure anything to run the application. If you have\n[installed Symfony][4], run this command and access the application in your\nbrowser at the given URL (\u003chttps://localhost:8000\u003e by default):\n\n```bash\n$ cd symfony-bundle-skeleton/\n$ symfony serve\n```\n\nIf you don't have the Symfony binary installed, run `php -S localhost:8000 -t public/`\nto use the built-in PHP web server or [configure a web server][3] like Nginx or\nApache to run the application.\n\nExamples\n--------\n\n**Macro example:**\n\nAdd this snippet into `templates/blog/index.html.twig` before `\u003carticle class=\"post\"\u003e`:\n\n```twig\n{% import \"@{your_namespace}/{your_namespace}_widget.html.twig\" as {your_namespace}_widget %}\n{{ {your_namespace}_widget.bar('https://github.com/msalsas/symfony-bundle-skeleton', 34) }}\n```\n\nGo to \u003chttp://127.0.0.1:8000/en/blog/\u003e\n\nYou will see the logic of the `bar` macro applied to each blog post\n\n**Persisting entities example:**\n\nThere is an already created example with a Car entity. If you run:\n\n```bash\n$ php bin/console doctrine:schema:update --force\n```\n\na new table `{you-domain}_car` will be created\n\nTo create new entities you can use the created service. E.g. create a route in\n\n`src/Controller/BlogController.php`\n\nwith the next action;\n\n```php\n/**\n * @Route(\"/car/random\", methods=\"GET\", name=\"create_random_car\")\n **/\npublic function postRandomCar(Service $service): Response\n{\n    $cars = ['BMW' =\u003e ['Serie 3', 'X5'], 'Mercedes' =\u003e ['Benz CLA', 'Benz GLS'], 'Seat' =\u003e ['Leon', 'Ibiza'], 'Toyota' =\u003e ['Corolla', 'Yaris']];\n    $brand_index = rand(0, 3);\n    $model_index = rand(0,1);\n    $brand = array_keys($cars)[$brand_index];\n    $model = $cars[$brand][$model_index];\n    $service-\u003ecreateCar($brand, $model);\n    $cars = $service-\u003egetCars();\n\n    return $this-\u003erender('cars/index.html.twig', ['cars' =\u003e $cars]);\n}\n``` \n*Use the service from your namespace*\n\nAnd now create a new twig template:\n\n`templates/cars/index.html.twig`\n\nand add the next content:\n\n```twig\n{% extends 'base.html.twig' %}\n\n{% block body_id 'blog_index' %}\n\n{% block main %}\n    \u003ch2\u003eCreate random car:\u003c/h2\u003e\n    \u003ch3\u003e\u003ca href=\"{{ path('create_random_car') }}\"\u003eCreate\u003c/a\u003e\u003c/h3\u003e\n    \u003cbr/\u003e\n    \u003ch2\u003eCreated cars:\u003c/h2\u003e\n    {% for car in cars %}\n        \u003ch3\u003eCar from {{ car.user and car.user.username ? car.user.username : 'anon.' }}\u003c/h3\u003e\n        \u003cp\u003eModel: {{ car.model }}\u003c/p\u003e\n        \u003cp\u003eBrand: {{ car.brand }}\u003c/p\u003e\n    {% endfor %}\n{% endblock %}\n```\n\nIf you go to \u003chttp://127.0.0.1:8000/en/blog/car/random\u003e you will see an already created car and a link to create random cars.\nAs you click on the link, new random cars are created.\nIf you go to the backend and log in and then go back and create new cars, you will see that the related user is the logged in user.\n\nTests\n-----\n\nExecute this command to run tests:\n\n```bash\n$ cd symfony-bundle-skeleton/\n$ ./bin/phpunit\n```\n\n[1]: https://github.com/symfony/demo\n[2]: https://symfony.com/doc/current/reference/requirements.html\n[3]: https://symfony.com/doc/current/cookbook/configuration/web_server_configuration.html\n[4]: https://symfony.com/download\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsalsas%2Fsymfony-bundle-skeleton","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmsalsas%2Fsymfony-bundle-skeleton","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsalsas%2Fsymfony-bundle-skeleton/lists"}