pablo-sg-pacheco / wp-namespace-autoloader Goto Github PK
View Code? Open in Web Editor NEWA PHP autoloader class that follows the WordPress coding standards applying PSR-4 specification
A PHP autoloader class that follows the WordPress coding standards applying PSR-4 specification
Updating the Coding standards for modern PHP (March 20, 2020)
I'm not sure how much needs to be changed here, just posting FYI.
Hello!
Does this project encourage developers to write custom - meaning abnormally structured - code?
I think when you write code for WordPress and you have class autoloading on mind you use PHP >= 5.3.0 namespaces and follow WPCS or PSR-4.
e.g. https://github.com/szepeviktor/debian-server-tools/blob/master/webserver/wp-install/wordpress-autoloader.php
e.g. simply use Composer's generated autoloader (vendor/composer/*.php
) for PSR-4
How do you see this?
I tried this on a project but my PHPUnit code coverage began reporting 0% code coverage. Once I used require_once
for each class, it began working again. Is there a sample project I can follow so I know I have it configured correctly.
Currently Composer errors out
Could not find a version of package pablo-sg-pacheco/wp-namespace-autoloader matching your minimum-stability (stable).
Hi, first of all thank you for this class.
I need to know if you can use it to manage multiple directories.
In practice a coding similar to the following:
includes/my_classes
and admin/includes/my__other_classes
and public/includes/my_other_classes
and so on
Thanks in advance
Adriano
@pablo-sg-pacheco This is my first try on autoloading WordPress core: https://github.com/szepeviktor/wordpress-autoloaded
It uses Composer and is basically a shell script.
What do you think?
In the classes_dir parameter, we have to specify the directory where our classes are located which we want to use for autoloading. For example, you said that if the classes are in the 'src' directory we have to specify 'src', and if the classes are in the root directory, nothing needs to be set.
My question is if we have split our classes into different directories, for example:
In root_dirctory/admin/includes (it holds admin classes) and root_directory/public/includes (it holds public classes)
In the above scenario, what do we have to specify in the classes_dir parameter? Should we leave it empty or should we write the name of both directories that holds our classes like:
'namespace_prefix' => 'My_Project',
'classes_dir' => [ 'admin', 'public' ]
Looking forward to your instructions on it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.