How to use psr-4 in the Composer with different subfolders

Asked

Viewed 51 times

0

How to configure my directories in composewr.json,

My directories are like this and not right

Vizuare
  -vendor
    -composer

    -php-class
       -src
         -DB
         -Model
         -Page.php


    -phpmailer
    -rain
    -slim
    -autoload.php

-views
-views-cache
composer.json
composer.lock
index.php

Why my folder structure is not working?

  • Your codes are in php-class? There is the file composer.json in this directory? What is its content? What are the namespaces in PHP files?

  • PHP yes HTML inside views

  • { "name": "Julio/vizuare", "Authors": [ { "name": "Júlio Silva", "email": "" } ], require": { "phpmailer/phpmailer":"5.2.22", "slim/slim":"2.0", "Rain/raintpl":"3.0.0" }, "autoload": { "psr-4": { "Launch ": "vendor php-class src" } } }

  • this and my Commander

  • But this file is in the root directory or inside php-class? There must be two files, one in each directory.

  • It depends a lot on the namespaces you will use in the files, I would personally recommend that you use the namespaces as a "directory" scheme, so the organization is intuitive and you only need to define the "main namespace". Just to feature, the sell folder should usually count the libs and 3rdparty packages, things like settings, models and the like "from the application" should be elsewhere.

  • My root folder and Vizuare and inside this directory are my vendor folders, views, views-cache. within vendor this my folder Composer, class-php, phpmailer, Rain and slim. Inside class-php are all my php codes, and inside views are my html pages

  • I think you’re mixing vendor with the application, this is not the purpose of the folder "vendor", I think you did not understand well what is the composer still, I personally recommend not using or structuring something that if you still don’t understand well how it works friend. You can take a look at popular frameworks to see how they organize the Models, Views and Controllers, an example is Laravel: https://laravel.com/docs/5.4/structure (of course not to follow the lines, it’s just to understand and create your own)

  • I appreciate the tip, very valuable

Show 4 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.