Use Laravel Html and Form facades inside standalone view package - php

I have a legacy PHP project that I'm working on bringing some framework components into. I'm starting by bringing Laravel's standalone View package into it. I've used the following to get the Views in and functional inside my legacy project:
https://github.com/mattstauffer/Torch/blob/master/components/view/index.php
The views are working fine, but I'd like to use Laravel's Html and Form packages (https://github.com/mattstauffer/Torch/blob/master/components/view/index.php) in my views as well. I've included "laravelcollective/html" in my composer.json file, but I'm not sure how to make it work with the standalone Views package.
Eventually, I will rewrite the legacy system using a framework from the start, but for now, I'd like like to bring a couple pieces into it.
Just to reiterate, I'm not trying to bring Html and Forms into the full Laravel installation (I know how to do that). I'm just looking to bring that functionality into the standalone Views package to use with the legacy system.
Thanks in advance!

Related

Laravel - share functionality between multiple separate codebases

So I have a project here that consists of several websites, and rather than writing functionality such as a login flow and signup flow into each project codebase I’m looking for a way to write these shared components once and include them as dependencies into all of the required codebases.
The login flow, for example, consists of:
model,
view
controller
repository
JavaScript
css
unit tests
database migrations
all other code related to the login flow
I would really like to be able to just include these shared functionalities via composer for example. Is there a way to do this?
Docker community edition, Laradock, Laravel 5.7, PHP 7.2, composer.
if you need to Share function you can make this function in helper function then put path in autoload path this link will help you for more understand

Conventions project with PHP and VueJs?

Basically I don't know how to start implementing VueJs into my project.
Should I use a CDN or require it via NPM? NPM would make it easier to implement VueJs packages.
I have in (my own framework (for learning)) a path /public/ in which a index.php file is located, along with an assets folder (which leads is followed css/js folders).
So the question is, what would you recommend, and how would you implement routing etc.?
I personally prefer it to be independent and would download the necessary files and integrate it directly.
Download the development version: https://vuejs.org/js/vue.js and the production version: https://vuejs.org/js/vue.min.js
Copy this files into the public/js folder
Add a script tag: <script src="js/vue.min.js"></script>
I don't get what the really point is on your question, but:
In your case I would use a framework like laravel, symfony, zend, ...
This gives you routing and stuff.
If you want to write the framework yourself (for learning, like you've mentioned) the you should take your brain and implement a concept on how you would like to define the routings.
Concerning VueJs: I think there should be no problem using the CDN-Version. It keeps things simple, until you really need to build VueJS on your development-PC (later within your deployment-process).
As said: Do one step after another. First use the simple way. Implement a simple Routing. Use VueJS from CDN. And when things get serious: Extend the code by your needs. Include VueJS via NPM and stuff like that.

Using composer to replace MVC Framework

i'm building a new project on top of CodeIgniter MVC framework, but now that i'm looking at the design, i will actually not use most of the framework features except for 1.form validation, 2.router and 3.session/cookie/input handling, and 4.views generation
even for database i will use Redbeans php ORM.
So my question
how can i glue these components that i fetched with composer from other frameworks so i can inject them into my project and be good to go without other extra stuff that i don't need ?
would it be a wise decision ? or is there any risks of depending on components rather than whole framework ?
i have googled a lot but it seems like i'm using the wrong keywords or something, i could not find any tutorial except for this one -which dictate symphony- that teach you how to do this and what are the risks of doing it
You can take a look at Packagist to explore which components Composer offers, RedBeanDB is definitely in there. However, in contrast to Symfony, CodeIgniter is not really Composer-friendly. So if you are looking for a proper way to just load these few CodeIgniter components as a dependency, I guess you're out of luck.
To keep from digressing, I'm simply going to answer your two main questions:
1) There are plenty of tutorials out there on how to use composer to grab your packages, so I wont do a full writeup, but basically what you need to do is download composer, create a composer.json file, then run composer to have it download all those packages and their dependancies. All you then need to do is in one of the already loaded codeigniter files, autoload the autoload.php file
`require 'vendor/autoload.php';`
Check the composer documentation here on how to download composer and setup your json file.
2) Definitely. The Laravel framework is actually built this way under the hood, instead of writing everything themselves, they use composer to pull in packages from other projects like Symfony to do certain tasks.

Best practice for Laravel 4 + Zurb Foundation 5?

TL;DR: what is the best way to arrange files, package managers and build tools for Laravel 4 + Zurb Foundation 5 combo (with Compass) as one consistent repository with clean public (static) section?
I wanted to start a fresh project, based on latest Laravel on the backend side and using Foundation for the frontend. I am new to both of these and apparently I missed some of the tooling that was developed meanwhile when I wasn't doing PHP for some time.
My confusion:
Laravel uses Composer for installation and dependency/module management. (Ok, I'm new to Composer)
Foundation is available as a Composer module (but then what?), but generally also as a CLI tool that creates a new project and uses bower for module/dependency management. But then I have two repositories.
Is it required for me to expose all my .scss files, or maybe even put the whole Foundation project into laravel's public dir to make all work?
How do people usually approach using these frameworks together? They shouldn't interfere, but they still have totally different tooling.
Where do I put my foundation files? Keep it as composer module or inside public? How to refer to them? How to have one build everything command?
I have the same issue as using Bootstrap SCSS version for Admin & Foundation SCSS for the frontend. I noticed also that both css frameworks come as composer packages however the issue you have with this approach is that you generally use other Javascript files in a development that will be merged also so using the composer versions just adds to the confusion.
The best solution i found was using either gulp or grunt with bower at the top level of your Laravel build. Rather that go through the configuration for you there is a good article at http://blog.elenakolevska.com/using-grunt-with-laravel-and-bootstrap/ that goes over a bootstrap integration but this can be tweaked for Foundation. This solution is good as grunt has many of the other popular javascript libraries that you may use in your project also..
Alternatively you could use an application like codekit and create a compass project to manage the merging & compiling of your assets into the public folder. As a side note if using git again your would need to exclude additional folders from your project.
If you think of your SCSS framework files as development assets there is no real need for them to be in the project as you only really need one version of Foundation on your development machine.
Your custom SCSS changes can be added to your Laravel project as modules ie a navigation module, via a private composer repo for the project or just added to the Compass project at development time. Your public folder should only be referencing the final merged style.css & java.js files for example. Any images from the framework can then just be copied over to the public folder ie icons etc.. Hope that helps..
Personally I have a "static" directory which houses static files. That is where I use SASS watchers, grunt tasks and basically the entire front-end workflow. The results of that front-end build process gets added to a "production" Laravel public directory after getting built, etc.
A pro of this is that everything (static assets and laravel application) is separate.
A con is that updating Laravel views with any updates in HTML templates you may build in the static directory. If you update the templates, you may also need to update the view files, which becomes more tedious as you add more templating logic around the HTML in the views.
Just one suggestion.

Using Laravel bundle with CodeIgniter

I want to use Laravel Bootstrapper bundle http://bundles.laravel.com/bundle/bootstrapper with my CodeIgniter application.
How can i utilize autoloader functionality to use Bootstrapper bundle code in CodeIgniter in native PHP 5 fashion.
Button::make('Abc')->with_icon('ok');
Do you suggest to convert Bootstrapper bundle in CodeIgniter library or we can use it as it is.
I am using bootstrap for creating views, thus already including bootstrap specific css, js & images.
Please help, so that the bundle can be used with CodeIgniter
Why? It's not designed to work with CI, you'll probably have to mess about alot to get it working. See one of the many versions available for CI here https://github.com/vesparny/codeigniter-html5boilerplate-twitter-bootstrap.
Further more, I dont see any great advantage of having a bootstrap CI integration, if you do then go for it but I just use my own customised bootstrap and load it in as normal in template/view files. Works just fine and keeps all those UI/view bits and pieces separate for designers/Front-end coders who panic at the sight of php.
All this work trying to keep design, function and layout separate and people go to great effort to ruin it with something like this.

Categories