I'm working on releasing a PHP framework I have been using for a few years
on github. Been trying to read up on the most correct way a project
should be structured, what extra files such as readme's etc should be
added. Been coming up with blanks on google. Can anyone point me to a
project that's a good example or any good write ups.
Some PHP projects hosted on Git(hub) include:
CakePHP
Gallery3
Garden
PHPUnit
Kohana
I'd just make sure that no temporary files, etc. get in the repository by creating a .gitignore file, and add some readme's etc. to the root of the repository.
Any configuration files should also be ignored, and sample configuration files should be created in the repository.
I'd recommend writing the readme file in a format that Github supports, like Markdown. It'll make your repository front page look better.
You might want to follow some kind of class naming guideline to make things like autoloading easier to implement. For example, the class MyFramework_Controller should be located at directory /lib/MyFramework/Controller.php.
You should just create some kind of basic layout for now - it'll be easier to give suggestions when we can see what you have right now.
Related
This is probably a pointless question but figured theres no harm in asking.
I have inherited a website which from what I can gather is using some Zend libraries and Doctrine... I think, excuse my ignorance as I'm not very clued up on the Zend framework.
In anycase I have been asked to update the numerous instances of depreacated code in among it. Which I thought would just have been within the application code so I could just update functions here and there etc etc.
It turns out most of the code needing updated is within the library folder which from what I can gather is all libraries which I would have thought would have been set up using composer but theres no mention of a composer.json file within the codebase.
So im now at a loss as I have a bunch of libraries that I have no idea how to update. Which brings me to my question, what would be the best way to attack this problem?
I was thinking if there was someway to reverse engineer a composer.json file based on the contents of the aforemetnioned library folder, that would be a good start as I could then use that as the basis for replacing the library folder with the updated libraries pulled in by composer but I have a feeling im probably clutching at straws.
To give some idea, this is the top level folder structure of the library folder:
Given the amount of subfolders within those listed and all the dependencies no doubt involved I would imagine manually updating them would be a nonstarter.
Would be interested to get thoughts on the best course of action here.
If I were in your spot I would create a composer.json and add try to add the libraries from the folder one by one and check if the app still works and fix dependencies one by one, I also see there is a vendor folder in there, that may have been the result of a composer.json which could be easily added in a new composer.json, but you will have to take the libraries one by one.
I have created a set of class files that helps to create the route configuration array. I, however, do not know where to put the source files. I browsed around a little and found some answers that suggested I put up the code in packagist and install it via composer, but my classes are relatively small. So, I wanted to ask if there is another way to do it. The files must be accessible in all the modules.
Your application code is organised into modules and lives in module/<Modulename>/src/. If the code is something you might want to reuse in other applications, then it might make more sense to have it as a standalone library that you install via. Composer.
You're code is accessibly through all the application if it is configured in the composer.json's autoload section.
Code structure in ZF is quite simple. You have your modules and in every module you have an src directory. This src directory should have its own namespace. And there you can place your custom route configurator under this namespace, like 'ModuleName\RouteConfigurator'.
But if you use this logic through multiple modules, I suggest you to create a separate module for it. In this case, after a long road, you may consider creating a separate composer package from it. But it's not necessary.
If you're not familiar with defining modules, please read the zend-modulemanager's documentation (https://docs.zendframework.com/zend-modulemanager/intro/)
We develop in PHP and HTML/Javascript.
Over time we developed a very big source code library, that contains a couple of hundred PHP and Javascript libraries, that we use for every project. The framework resides its own svn-repository, that we include with an external svn link in each project.
The problem is, that the entire framework itself is about 800MB now.
With only a few projects that we worked on, this wasn't really a problem, but now we have about 30 projects, that all contain a FULL copy of the framework, which takes up a lot of space, and requires constant updating of each copy.
Somehow I would like to have the framework outside the project folders. I've read about referencing other projects in Eclipse, but couldn't really get it to work.
How do you setup the include paths so that each projet 'thinks' that the framework is normally inside the project folder? And can you make a virtual link in an Eclipse project to edit files in the framework just as you would normally do, and get code assist for the libraries too?
One of the main problems is that all our code (and some libraries in the framework itself too) relies on the fact that the framework is in a folder 'framework' inside each project. I'd rather not change all those references to a different path, so maybe I need some .htaccess trick to make this work...
Does anybody else follow the same procedure?
Any advice ?
can you use the "big" project as target platform?
why-create-a-custom-target-platform
If you define it as target platform, the sources are available in your workspace, but they are placed in 1 folder for multiple workspaces. the workspaces will link to the platform, but will not check them out.
It is generally adviced to store module assets inside the module's directory, inside moduleName/public (or whatever you want to name the asset's directory).
Zend Framework 2 unfortunately doesn't support asset publishing for module assets by default. According to MWOP, there was nothing planned ~1 month ago and I guess there still is no real plan (they had probably a lot of work to get the stable version ready). (But, some day, they are going to address this issue.)
As my ZF2 app is growing and growing, I reached the point where I need to have module-specific assets. At the moment, I maintain them inside the module directories and copy them to the application's public directory. You can imagine that this method is error-prone and exhausting.
How do you handle this problem? Is there maybe a simple solution to this issue with little coding effort? My project plan doesn't allow me to create a complex asset handling on my own. Is there a recommendable, lightweight asset framework compatible to ZF2? I've already considered creating symlinks but I don't think this would be the best solution because it would require some additional web server configuration (FollowSymlinks) and additional maintenance work (the app is developed locally and deployed on a remote server).
Thanks in advance.
This has been discussed before in many places and it comes down to three ways to manage this.
Copy and Paste the assets into the public/ directory
Use symlinks
Use an asset loading module like assetic
A simple solution would be to make the copying of assets part of you build process.
Another question was already asked How to merge Zend Framework 2 module public directories for info.
I know this is pretty old, but I wanted to add this information for other readers.
Now there's also a module for this, which has been fully tested and is being used (and even depended on) by many modules.
Check it out here: https://github.com/RWOverdijk/AssetManager
Hope this helps.
There is also fourth option. Use a directory Alias in VirtualHost configuration.
I have a PHP Platform that I've built.
I use a copy of that project for each project I do.
I add assets and configure each project with it's own content.
Configuring a project changes some of the core files which contain
the configuration defaults.
When I update core files in the library/platform itself and I want to disseminate those changes to all of the other projects using that platform, what would be the best approach?
I think it may be worth noting that I have each project as an SVN project in Eclipse.
UPDATED DETAILS:
The platform is based on AMFPHP 1.9.
AMFPHP has a services folder.
I have to put core services in the services folder as well as
implementation specific services and therefore cannot achieve
complete separation between the "library" and the "application".
Also, the default configuration files need to be in the "platform" folder
so they can be easily distributed with it, but when configuration is
changed, those files become "implementation specific" as well.
Is there a solution that will allow me to designate certain files to update?
Take a look at the use of svn:externals. Configure each secondary project with your core libraries as an external.
Excellent question, here's the way I solved this problem with my own PHP framework.
If you have all the project-specific and core files mixed together, and platform code interspersed with your project code, it's going to be really difficult to update the core code to all of your projects.
The best way to get around this is to make it easier for svn (or git, or any other versioning software) to update your files: if they're all neatly organized, with project and core files in their respective places. Let me give you an example to clarify.
Put all of the core files of your framework in this directory:
/App/FrameworkName
Here you can place core classes, functions, and other code that won't change for all of your different projects.
Then, any project-related content, settings or pages go in:
/App/Project
Here, you have all of the data that your projects use.
With this system, if you add a feature to your platform, all you have to do is svn the latest version of your framework to /App/FrameworkName, and your project will be using up-to-date code.
My programs are usually organised in two parts. the core framework folder, and the addon folders.my framework (in house) does all the initial work then loads the addon for additional functionality.
For example, the framework deals with all the user auth , the addon provide additional crud functions the each project needs.
That way, i can keep them in separate repository. and the framework can be checked out and used for other projects.