Old symfony directory structure better? [closed] - symfony

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 months ago.
Improve this question
I have seen that new symfony projects have a diffrent directory stucture. Mainly the ressources-folder is not used anymore. I personally found that old structuring very nice, since all ressources were where they were used. When I start using bundles. it feels wrong to have all in the root folder. This is clearly an opinion, but I got a question from that, and the following question is not about opinion, but in practicality of the old structure in Symfony > 6:
What is the benefit of the new folder structure compared to the old approach with src/Ressources? Is there an advantage to the new structure which I don't see, or is it just a matter of taste and i can go the old way?
Your inputs are highly appreciated
Old approach
Root/
├─ src/
│ ├─ Ressources/
│ │ ├─ config/
│ │ ├─ public/
│ │ ├─ js/
│ │ ├─ styles/
│ │ ├─ views/
│ │ ├─ translations/
New approach
Root/
├─ src/
├─ public/
├─ templates/
├─ translations/
├─ config/

First of all, you can use old structure in new Symfony versions too! It all depends on few configurations.
To me, new structure is better, it makes more sense to move most things out of Resources directory into assets.
So it should really be:
├─ root/
│ ├─ config/
│ ├─ src/
│ ├─ public/
│ ├─ views/
│ ├─ translations/
│ ├─ assets/
│ │ ├─ js/
│ │ ├─ styles/

Related

nextjs page contains a space is not triggered but /pages/page%20title does

i have this following structure under pages
├─ pages
│ ├─ index.tsx
│ ├─ betting
│ │ ├─ [bet].tsx
│ │ ├─ ippica live.tsx
into index.tsx i have a next/link that redirects to ippica live, in the url i have localhost:3000/betting/ippica%20live
but ippica live.tsx is not triggered but [bet].tsx does
i noticed that if i rename the file ippica live.tsx into ippica%20live.tsx all starts working but is very ugly and unconvenient
is there any other clean solution other than applying %20 into the file name?

Sass not finding correct filepaths

I want to use sass to write individual components, for example styling a chart. But I don't want to manually include every component, but rather have one scss file that includes all the components and then gets compiled to one .css file that I can include. I found this SO answer but it didn't work for me and according to SASS, you're not supposed to use #import anymore. This is the project structure:
src/
├─ about/
│ ├─ .../
│ ├─ scss/
│ │ ├─ chart.scss/
├─ app/
│ ├─ scss/
├─ build/
│ ├─ css/
| | ├─ styles.css
├─ base/
│ ├─ styles.scss
styles.scss should include all scss files from all projects in the src, and should be compiled on every .scss save. When I do it with this command though:
sass base/styles.scss:build/css/main.css --watch --style=compressed --no-source-map
it gives the error:
Error: Can't find stylesheet to import.
╷
1 │ #use "//about/scss/chart.scss";
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
╵
base_templates\styles.scss 1:1 root stylesheet
The content of styles.scss is
#use "//about/scss/chart.scss";
and that of chart.scss:
h1 {
color: #fff;
}
(as a test). What am I doing wrong?
The path should be "/src/about/scss/chart.scss" for Sass if src is the source of the volume respectively partition. Sass never 'knows' anything about your domain or network, therefore you can't assume that you can use paths based on the webroot as absolute paths.
You can also consider using relative paths, then it would be '../about/scss/chart.scss'.

Artifactory zip directory with exclude pattern

I do store my software releases in Artifactory.
As a minimal example my repository structure looks like this:
my_repo/
├─ release-1/
├─ release-2/
├─ release-3/
│ ├─ reports/
│ │ ├─ trace.pzip
│ │ ├─ cov_report.html
│ ├─ release/
│ │ ├─ app.exe
│ ├─ debug/
│ │ ├─ app_debug.exe
Now I want to create different zipped deliveries. E.g. so that we do have an internal release package (release-3_woDebug.zip), one for the end customer (release-3_woreports.zip), etc...
my_repo/release-3/ contains all files of the release, to create the packages I want to exclude specific files.
my_repo/
├─ packages/
│ ├─ release-3-packages/
│ │ ├─ release-3_woDebug.zip
│ │ ├─ release-3_woreports.zip
├─ release-1/
├─ release-2/
├─ release-3/
Is there a simple REST or jFrog CLI command which I can use to create such zip files.
When looking at the documentation, the jf rt download (ref) command has an --exclusions option which looks already promising.
But is there a way to create such packages (zip files) without downloading the content first?

Julia `julia --project` argument use

I learned of a way to run julia, so I can use the file structure of a package for my project.
Namely julia --project inside my developement directory. With this I can load all projects structured like projectName/src/projectName.jl inside the same folder.
An Example:
all my julia projects/
├─ project 1/
│ ├─ working with files in julia.jl
│ ├─ data.csv
├─ project 2/
│ ├─ project.toml
│ ├─ src/
│ │ ├─ project 2.jl
├─ project 3/
│ ├─ draft.uxf
│ ├─ .gitignore
│ ├─ project.toml
│ ├─ auto_compile.jl
│ ├─ src/
│ │ ├─ project 3.jl
With this file structure I want to call auto_compile.jl that does the following:
using Pkg
cd("..")
Pkg.activate(".")
Pkg.instatiate()
Pkg.add("PackageCompiler")
using PackageCompiler
create_app("Project 3", "Project 3 Compiled")
However, PackageCompiler.jl only works with the --project command. The --project argument doesnt seem to modify LOAD_PATH, what does it do exactly? Can I edit my julia session with --project later on? I figured julia does the same when loading packages from the ~user/.julia/packages/ dir, but how do I do that, and are there more usefull arguments I should know about?
after some quick "testing" I can confirm:
the --project/--project=. flags when starting julia from the terminal do the same as Pkg.activate(".")

Extends entity and repository

I want to create some core for my Symfony app.
The composer create-project will be included my core provided by Github repository.
Structrue of project:
Symfony-project/
├─ app/
├─ src/
│ └─ AppBundle/
│ └─ Entity/
│ └─ Category
│ └─ Repository/
│ └─ CategoryRepository
├─ tests/
├─ var/
├─ vendor/
│ └─ core/
│ └─ src/
│ └─ bundles/
│ └─ Entity/
│ └─ Category
│ └─ Repository/
│ └─ CategoryRepository
└─ web/
I want extends vendor Entity and Repository by src/AppBundle Classes.
I used annotations inside Entity.
How did solve this problem?
I think about extend class by base category and mark is as final:
<?php
namespace AppBundle\Entity;
use Vendor\Namespace\Category as BaseCategory;
use Doctrine\ORM\Mapping as ORM;
/**
* #ORM\Entity
*/
final class Category extends BaseCategory
{
In next step add some rules inside app/config/config.yml e.g.
my_core:
extended_entities:
Vendor\Namespace\Category: AppBundle\Entity\Category
and use compillerpass to change metadata
About the Repository I think about the same thing as above or maybe register is as service(??)
But I think it's a little bit reckless and I'm looking for some clues how to do it better.

Resources